When we execute the following code:
#include <stdio.h>
int main(void){
char x,y;
scanf("%c", &y);
x = getchar();
putchar(x);
return 0;
}
The enter that is being inputted in the scanf("%c", &y);
statement is passed on to x. Is there some way to get away with this? I now that if we are using scanf
then we can ignore the \n
by scanf("%*c%c", &x);
but don't know what do while using getchar()
.