Home > Back-end > C language gets function does not work
C language gets function does not work
Time:09-28
# include & lt; stdio.h> # include & lt; String. H> Int main () { Int n, I; The scanf (" % d ", & amp; N); The char b [80], min [80]. getchar(); Gets (min). for(i=1; I{ Gets (b); If (STRCMP (min, b) & gt; 0) Strcpy (min, b); } Min is: printf (" % s ", Min); return 0; }
# include & lt; stdio.h> # include & lt; String. H> The main () { Int N, I, a; Char STR [1000] [80], * c. The scanf (" % d \ n ", & amp; N); for(i=0; IGets (STR [I]); C=STR [0]. for(i=1; I{ If (STRCMP (c, STR [I]) & gt; 0) C=STR [I]; } Min is: printf (" % s ", c); } Why don't the second paragraph add getchar can also normal execution, and the first period of not less execution gets
CodePudding user response:
Gets is met a newline returned, so the first if not getchar, then input after n '\ n' will be gets (first) receiving, return directly,