Gets (): Enter the string directly, only the string can be entered. Gets () thinks that spaces are also part of a string, and string input ends only when the Enter key is encountered. So no matter how many spaces you enter, as long as you don't press Enter, it is the complete string of gets (). In other words, gets () is used to read a whole line of strings.
Extended data
Use of scanf () and gets ():
# include & ltstdio.h & gt
intmain(){
charstr 1[30]= { 0 };
charstr 2[30]= { 0 };
charstr 3[30]= { 0 };
//Get the usage of ()
printf(" input astring:");
gets(str 1);
//scanf () usage
printf(" input astring:");
scanf("%s ",str 2);
scanf("%s ",str 3);
printf("\nstr 1:%s\n ",str 1);
printf("str2:%s\n ",str 2);
printf("str3:%s\n ",str 3);
return0
}
Baidu Encyclopedia-Access
Baidu encyclopedia -—scanf