xref: /csrg-svn/lib/libc/stdio/gets.c (revision 26656)
1 #if defined(LIBC_SCCS) && !defined(lint)
2 static char sccsid[] = "@(#)gets.c	5.2 (Berkeley) 03/09/86";
3 #endif LIBC_SCCS and not lint
4 
5 #include	<stdio.h>
6 
7 char *
8 gets(s)
9 char *s;
10 {
11 	register c;
12 	register char *cs;
13 
14 	cs = s;
15 	while ((c = getchar()) != '\n' && c != EOF)
16 		*cs++ = c;
17 	if (c == EOF && cs==s)
18 		return(NULL);
19 	*cs++ = '\0';
20 	return(s);
21 }
22