G
Gus Tabares
Hello,
I'm having trouble reading in a character. Here is a snippet of code:
int num;
char character;
printf("Enter a number: ");
scanf("%d", &num);
printf("You entered %d.\n", num);
printf("Enter a character: ");
scanf("%c", &character);
printf("You entered %c.\n", character);
When I run this, I get:
Enter a number: 3
You entered 3.
Enter a character: You entered
..
I'm not sure why I'm unable to enter in a character before the last
printf is executed. I'm also tried this with getchar(), with the same
result.
Any help is appreciated.
I'm having trouble reading in a character. Here is a snippet of code:
int num;
char character;
printf("Enter a number: ");
scanf("%d", &num);
printf("You entered %d.\n", num);
printf("Enter a character: ");
scanf("%c", &character);
printf("You entered %c.\n", character);
When I run this, I get:
Enter a number: 3
You entered 3.
Enter a character: You entered
..
I'm not sure why I'm unable to enter in a character before the last
printf is executed. I'm also tried this with getchar(), with the same
result.
Any help is appreciated.