TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Edward Fuller
from: Bill Patterson
date: 1995-08-05 19:58:38
subject: Re: GCC2

* In a message originally to Edward Fuller, Bill Patterson writes:

 EF> The following is taken from K&R's book "The C Programming
Language", page
 EF> 165, 1st edition:
 EF> 
 EF> /* fgets: get at most n char from iop */
 EF> char *fgets(char *s, int n, FILE *iop)
 EF> {
 EF>    register int c;
 EF>    register char *cs;
 EF> 
 EF>    cs = s;
 EF>    while (--n > 0 && (c = getc(iop)) != EOF)
 EF>       if ((*ds++ = c) == '\n')
 EF>          break;
 EF> 
 EF>    *cs = '\0';
 EF>    return (c == EOF && cs == s) ? NULL : s;
 EF> }
 EF> 
 EF> Note: fgets reads the next input line (includeing the newline) from the
 EF> file iop into the character array s, at most n-1 characters will be read.
 EF> gets deletes the terminal '\n' and puts adds it.
 EF> 
 EF> --- FLAME v1.1

Edward,
   Yep, that's the code I tried. Won't work under gcc2. Works under EMX
though. Thanks!

Bill


--- LoraBBS-OS/2 v2.40+
EF> * Origin: HAL-PC - (713)963-4100 (1:106/4100)
* Origin: Planet X * Warp Co-Ordinates: 407-799-0975 (1:374/2528.0)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 515 628 704 713/888 800/1 7877/2809
@PATH: 374/2528 1 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.