I just want to read in a char from stdin, if it is a space, do something, if it is a newline, do something else. What is happening with my current code is if I enter a space, then hit enter, the ' ' case is satisfied which is what I want, but the '/n' case is also satisfied after that. I don't want to read in the space and the newline, all I care about is the space. How do I fix this? Here is my code:
int input = getc(stdin);
switch (input) {
case 'q':
return 1;
break;
case ' ':
printLines(fp);
break;
case '\n':
printLine(fp);
break;
default:
getResponse(fp);
break;
}