gets.c (209B)
1 #include <stdio.h> 2 3 #undef gets 4 5 char * 6 gets(char *s) 7 { 8 int ch; 9 char *t = s; 10 11 while ((ch = getc(stdin)) != EOF && ch != '\n') 12 *t++ = ch; 13 if (ch == EOF && s == t) 14 return NULL; 15 *t = '\0'; 16 17 return s; 18 }