gets() reads in only text : gets « stdio.h « C Tutorial






It reads everything typed at the keyboard until the Enter key is pressed.

#include <stdio.h>
 
int main(){
    char name[20];
 
    printf("Name:");
    gets(name);
    printf("%s \n",name);
    return(0);
}
Name:1
      1

gets(var) is the same as scanf("%s",var).









22.22.gets
22.22.1.gets
22.22.2.Using gets and putchar
22.22.3.gets() reads in only text