I write console application which performs several scanf for int
And after it ,I performs getchar :
int x,y;
char c;
printf("x:\n");
scanf("%d",&x);
printf("y:\n");
scanf("%d",&y);
c = getchar();
as a result of this I get c = '\n',despite the input is:
1
2
a
How this problem can be solved?
This is because
scanfleaves the newline you type in the input stream. Tryinstead of