+ 6
getchar() reads standard input and returns one char from it. gets() reads a string from stdin (But don't x it, use fgets instead) Ej.: #include <stdio.h> #include <stdlib.h> int main() {     char grade;     char name[20];     printf("input grade (a/b): ");     grade = getchar();     fflush(stdin);     printf("input name: ");     gets(name);     printf("%c - %s\n", grade, name);     return 0; }
1st Feb 2019, 4:01 AM
unChabon
unChabon - avatar
+ 1
https://www.sololearn.com/learn/C/2914/ getchar() is used when you read one single character from input stream. gets() is used when you read an array of characters. Hint: You can play with the Try It Yourself in each lesson a little bit, try changing the numbers/variable names/datatype and see what happens
1st Feb 2019, 4:01 AM
Gordon
Gordon - avatar