Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ gets(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

feof, ferror, clearerr, fileno

fopen, freopen, fdopen

fread, fwrite

getc, fgetc, getchar, getw

puts, fputs

scanf, fscanf, sscanf, NLscanf, NLfscanf, NLsscanf

standard i/o library

     gets, fgets

Purpose

     Gets a string from a stream.

Library

     Standard I/O Library (libc.a)

Syntax

     #include <stdio.h>

     char *gets (s)                            char *fgets (s, n, stream)
     char *s;                                  char *s;
                                               int n;
                                               FILE *stream;
     Description

     The gets  subroutine reads  characters from  the standard
     input stream, stdin,  into the array pointed to  by the s
     parameter.  Data  is read  until a new-line  character is
     read  or an  end-of-file  condition  is encountered.   If
     reading is stopped due to  a new-line character, the new-
     line character is discarded  and the string is terminated
     with a null character.

     The  fgets  subroutine  reads characters  from  the  data
     pointed to by the stream parameter into the array pointed
     to by the s parameter.   Data is read until n - 1 charac-
     ters have been  read, until a new-line  character is read
     and transferred  to s, or until  an end-of-file condition
     is  encountered.  The  string is  then terminated  with a
     null character.

     Return Value

     If end-of-file is encountered and no characters have been
     read,  no characters  are  transferred to  s  and a  NULL
     pointer  is returned.   If a  read error  occurs, a  NULL
     pointer is returned.  Otherwise, s is returned.

     Related Information

     In this book:  "feof,  ferror, clearerr, fileno," "fopen,
     freopen, fdopen," "fread, fwrite," "getc, fgetc, getchar,
     getw,"  "puts, fputs,"  "scanf, fscanf,  sscanf, NLscanf,
     NLfscanf, NLsscanf," and "standard i/o library."

     getservent, getservbyname, getservbyport, setservent,

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026