8000 minix/lib/stdio/gets.c at R3.1.3 · nirs/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
executable file
·
27 lines (22 loc) · 375 Bytes

gets.c

File metadata and controls

executable file
·
27 lines (22 loc) · 375 Bytes
/*
* gets.c - read a line from a stream
*/
/* $Header$ */
#include <stdio.h>
char *
gets(char *s)
{
register FILE *stream = stdin;
register int ch;
register char *ptr;
ptr = s;
while ((ch = getc(stream)) != EOF && ch != '\n')
*ptr++ = ch;
if (ch == EOF) {
if (feof(stream)) {
if (ptr == s) return NULL;
} else return NULL;
}
*ptr = '\0';
return s;
}
0