I would have thought the following code would print out integers if they were inputted......
I've read that when using getchar() or fgetc() you can use " c - '0' " in place of c in the printf statement to rectifiy the problem, (what does it do?) if i do so, i get the integer inputted printed to the screen but i also get a another negative number printed underneath it.Code:#include <stdio.h> int main() { int c; while ((c = fgetc(stdin)) != 'Q') printf("%d\n", c); return 0; }
Can someone tell me whats going on?
Many thanks.