The following segment of code is supposed to get characters and repeat them back at me until EOF is entered, variable c has been declared as int.
while((c = getchar()) != EOF)
{
printf("Debug:: c = %d\n", c);
}
However the debug output shows that getchar() is acting weird:
1
Debug:: c = 49
Debug:: c = 10
2
Debug:: c = 50
Debug:: c = 10
It seems like the loop is running once more everytime I hit enter. Is this a problem with:
a) This use of getchar in a while() condition (K&R says this is okay)?
b) A problem with gcc? (running on OS X)
c) Something else?
Please help...
Name:
Anonymous2006-07-30 19:43
The output is producing exactly what it should. You seem confused on the difference between EOF and a line feed.
The actual string you entered is "1\n" (i.e. 1 and then enter); thus getchar() parses that by first returning 1 (that's 49), then \n (that's the line feed you get from pressing the enter key, i.e. 10), then EOF (which exits the loop).
Name:
Anonymous2006-07-31 1:32
C sucks sure there's an ebuild for C but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, which means that it is a BINARY package.
Name:
Anonymous2006-07-31 1:39
Copypasta sucks sure there's an ebuild for copypasta but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, which means that it is a BINARY package.
Name:
Anonymous2006-07-31 2:25
Ruby sucks sure there's an ebuild for ruby but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, whitch means that it is a BINARY package
Name:
Anonymous2006-07-31 2:30
/prog/ sucks sure there's an ebuild for /prog/ but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, whitch means that it is a BINARY package
Name:
Anonymous2006-07-31 4:08
("%s sucks sure there's an ebuild for %s but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, whitch means that it is a BINARY package", string1, string2);
Name:
Anonymous2006-07-31 13:25
>>7 ("%s sucks sure there's an ebuild for %s but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, whitch means that it is a BINARY package", string1, string1);
fixed
Name:
__Guido van Rossum__2006-08-01 17:48
"%(name)s sucks sure there's an ebuild for %(name)s but it just get dropped to /opt, it's statically linked, and it's CLOSED SOURCE, whitch means that it is a BINARY package" % {"name": string1};
fixed
About the place Women and kids should stay the fuck would you take a remedial course That regex is pretty funny Unlike.
Name:
Trollbot90002009-07-01 11:03
That out vip quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality That was VIP quality.