I am reading over the KR book, and am a little stuck.
What is wrong with the following?
void getInput(int* output) {
int c, i;
for(i=0; (c = getchar()) != '\n'; i++)
output[i] = c; // printf("%c", c) prints the c value as expected
output[++i] = '\0';
}
When I run the program it never gets out of the loop and I have to ctrl-c to exit. However if I replace the 5th line with printf("%c", c);
it prints out all the input just fine after hitting enter and creating the new line.
Thanks for the help.