home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
163_01
/
gets.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
NeXTSTEP
RISC OS/Acorn
UTF-8
Wrap
C/C++ Source or Header
|
1988-02-01
|
512 b
|
24 lines
/*
** get a string from "stdin"
** terminate with \0
*/
extern int *stdin, fgetc();
gets(s) char *s; {
int n, ch;
char *str;
str=s; /* save original value */
n = 256;
while(--n) {
ch=fgetc(stdin);
if(ch<0) {
*s='\0';
return 0;
}
if(ch=='\n') break;
*s++=ch;
}
*s='\0';
return str;
}