Ignore this post!. Found solution to problem in the next chapter of book I'm learning from!
C beginner, trying to learn how to pass over '\n' in the following simple program. I just don't get it! Program gets stuck with ch = '\n'.
Code:
#include <stdio.h>
int main(void)
{
int oper;
char ch;
printf("Enter a character or \"q\" to exit\n");
ch = getchar();
while(ch!= 'q')
{
printf("Enter an integer:\n");
while(scanf("%d", &oper)==1)
{
printf("%d is the integer entered\n",oper);
printf("Enter a character or \"q\" to exit:");
ch=getchar();
}
}
return 0;
}
Thanks for your help.