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