|
|
1.1 root 1: /*
2: * libc/stdio/gets.c
3: * ANSI-compliant C standard i/o library.
4: * gets()
5: * ANSI 4.9.7.7.
6: * Read string from stdin.
7: * Do not retain newline.
8: */
9:
10: #include <stdio.h>
11:
12: char *
13: gets(s) char *s;
14: {
15: register c;
16: register char *cp;
17:
18: cp = s;
19: while ((c = getchar()) != EOF && c != '\n')
20: *cp++ = c;
21: if (c == EOF && (s == cp || ferror(stdin)))
22: return NULL; /* ANSI says leave *s unchanged */
23: *cp = '\0'; /* else NUL-terminate */
24: return s;
25: }
26:
27: /* end of libc/stdio/gets.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.