home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Extra Super CD 1998 January
/
PCPLUS131.iso
/
DJGPP
/
V2
/
DJLSR201.ZIP
/
src
/
libc
/
ansi
/
stdio
/
fgets.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1994-12-26
|
374 b
|
23 lines
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
#include <libc/file.h>
char *
fgets(char *s, int n, FILE *f)
{
int c=0;
char *cs;
cs = s;
while (--n>0 && (c = __getc(f)) != EOF)
{
*cs++ = c;
if (c == '\n')
break;
}
if (c == EOF && cs == s)
return NULL;
*cs++ = '\0';
return s;
}