man(1) Manual page archive


     GETS(3S)                                                 GETS(3S)

     NAME
          gets, fgets - get a string from a stream

     SYNOPSIS
          #include <stdio.h>

          char *gets(s)
          char *s;

          char *fgets(s, n, stream)
          char *s;
          FILE *stream;

     DESCRIPTION
          Gets reads a string into s from the standard input stream
          `stdin'.  The string is terminated by a newline character,
          which is replaced in s by a null character.  Gets returns
          its argument.

          Fgets reads n-1 characters, or up to a newline character,
          whichever comes first, from the stream into the string s.
          The last character read into s is followed by a null charac-
          ter.  Fgets returns its first argument.

     SEE ALSO
          puts(3), getc(3), scanf(3), fread(3), ferror(3)

     DIAGNOSTICS
          Gets and fgets return the constant pointer NULL upon end of
          file or error.

     BUGS
          Gets deletes a newline, fgets keeps it, all in the name of
          backward compatibility.