ack/lang/cem/libcc.ansi/stdio/gets.c
1989-05-30 13:34:25 +00:00

24 lines
296 B
C

/*
* gets.c - read a line from a stream
*/
/* $Header$ */
#include <stdio.h>
char *
gets(char *s)
{
register int ch;
register char *ptr;
ptr = s;
while ((ch = getc(stdin)) != EOF && ch != '\n')
*ptr++ = ch;
if (ch == EOF && ptr==s)
return (char *)NULL;
*ptr = '\0';
return s;
}