TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Bill Patterson
from: Edward Fuller
date: 1995-08-03 17:47:44
subject: GCC2

The following is taken from K&R's book "The C Programming
Language", page 165, 1st edition:

/* fgets: get at most n char from iop */
char *fgets(char *s, int n, FILE *iop)
{
   register int c;
   register char *cs;

   cs = s;
   while (--n > 0 && (c = getc(iop)) != EOF)
      if ((*ds++ = c) == '\n')
         break;

   *cs = '\0';
   return (c == EOF && cs == s) ? NULL : s;
}

Note: fgets reads the next input line (includeing the newline) from the
file iop into the character array s, at most n-1 characters will be read.
gets deletes the terminal '\n' and puts adds it.

--- FLAME v1.1

* Origin: HAL-PC - (713)963-4100 (1:106/4100)
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: 106/4100 3333 2000 380/25 270/101 105/103 42 712/515 711/808 809
@PATH: 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™.