Anonymous
Intel runs a mo
Marie
There are no blacklisted messages here!
Anonymous
Marie
Purge complete.
Anonymous
Ariana
Alignant
The best linux distro is
Alignant
Ponyos ^.^
Roxifλsz 🇱🇹
Ponyos ^.^
And this isn't even linux
Roxifλsz 🇱🇹
If you're going to be shitposting, please do it correctly
Anonymous
anyone ever tried resharper c++?
bdam
hi guys
bdam
I wrote a simple program inspired by an exercise from the C book (ritchie and Kernighan)
bdam
I have a weird bug and I can't fix it
bdam
could someone take a look at the 10 lines of code and help me out pls?
Roxifλsz 🇱🇹
klimi
klimi
Just add semicolon
klimi
I hope my crystal ball is working ok
Ariana
Isn’t bug like unexpected behaviour?
Dima
Imagine how much of undefined behaviours you can fit into 10 lines
Dima
especially in cxx
Alignant
bdam
Give me 30 min, not at work rn
Mat
Mat
If it is, use a paste site like the one in the pinned message
bdam
Ok great, thx
bdam
#include <stdio.h>
/*for every input by the user, the boolean value of c is determined and printed out*/
main()
{
int c;
c = 1;
while((c = getchar()) != EOF) {
c = getchar() != EOF;
printf("%d\n",c);
}
}
bdam
When I compiled & ran I noticed weird behavior
Dima
wtf
bdam
for example, when the input is:
bdam
ssssssssssssss
bdam
I get in return:
bdam
1
1
1
1
1
1
1
bdam
so 14x s and 7x 1
bdam
why is it not 14x 1?
Dima
use getchar once
bdam
oh, it's tokenized?
bdam
e.g it takes every second input cause I used getchar twice?
olli
bdam
Thank you guys. and now I feel dumb again lmao
Mdex Community
Anonymous
Anonymous
Hi, working on a small program that takes 3 numbers and returns the average. The online judge I use requests that I have 2 decimal places. Not sure what I am doing wrong here.
Anonymous
#include <iostream>
#include <iomanip>
int main(){
int a,b,c;
double by = 3;
std::cin>>a>>b>>c;
std::cout<<std::setprecision(2)<<(a+b+c)/by;
return 0;
}
Anonymous
I Googled, found out about setprecision, yet something is off and not sure what.
Anonymous
For 9 8 7...it returns 8 instead of 8.00
Anonymous
Also tried:
Anonymous
#include <iostream>
#include <iomanip>
int main(){
int a,b,c;
std::cin>>a>>b>>c;
std::cout<<std::setprecision(2)<<float(a+b+c)/float(3);
return 0;
}
Alignant
std::cout << std::setprecision(2) << std::fixed << (a+b+c)/by;
Alignant
Try add std::fixed
Anonymous
That works @Alignant TY!
Anonymous
Need to read more on std::fixed
Anonymous
http://www.cplusplus.com/reference/ios/fixed/
Anonymous
Is this an ok site for reading documentation or should I be using something else?
Alignant
And you shouldn't devide ints by doubles, it's confusing.
And there's nothing to read about it. std::setprecision doesn't enforce your number to have 2 digits after the dot
Alignant
Anonymous
So I should declare numbers a,b,c as floats or?
Alignant
double a = 10, b = 3;
std::cout << std::setprecision(3) << a/b << std::endl;
That would print 3.33. But
double a = 10, b = 3;
std::cout << std::setprecision(3) << a/b << std::endl;
But it would just print 3. setprecision sets the max precision
Alignant
Anonymous
ty ty!
Anonymous
Anonymous
and even if you wanted to do that check, you're calling getchar twice
Alignant
Anonymous
doesn't make any sense either
Anonymous
he is calling getchar() twice
Anonymous
already did that check
Alignant
This problem is already solved
Anonymous
salve a tutti, spero di non sbagliare nel fare qui una richiesta flin4cell per win10
Roxifλsz 🇱🇹
BinaryByter
Marie
BinaryByter
Marie