scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

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 }