shithub: scc

ref: 994751d39485e086ef623f202fb1b84729fd5d19
dir: /src/libc/stdio/gets.c/

View raw version
#include <stdio.h>

#undef gets

char *
gets(char *s)
{
	int ch;
	char *t = s;

	while ((ch = getc(stdin)) != EOF && ch != '\n')
		*t++ = ch;
	if (ch == EOF && s == t)
		return NULL;
	*t = '\0';

	return s;
}