cs240/hw/hw1/hw1-final/getchar.c

20 lines
481 B
C
Raw Normal View History

2018-10-15 17:20:57 -04:00
#include <stdio.h>
int main(){
char c;
printf("Enter a character:");
/*Grab the next character from stdin and store it in variable c, remember to account for the newline character*/
c = getchar();
getchar(); /* Consume the newline. */
printf("The character you entered was %c\n", c);
printf("Enter a second character:");
/*Grab the next character from stdin and store it in c again*/
c = getchar();
printf("The character you entered was %c\n", c);
return 0;
}