Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

clearerr(3)

feof(3)

ferror(3)

fileno(3)

fopen(3)

fread(3)

getc(3)

getwc(3)

getws(3)

puts(3)

putws(3)

scanf(3)

gets(3)  —  Subroutines

OSF

NAME

gets, fgets - Gets a string from a stream

LIBRARY

Standard I/O Library (libc.a)

SYNOPSIS

#include <stdio.h>

char ∗gets (
const char ∗string );

char ∗fgets (
const char ∗string,
int n,
FILE ∗stream );

PARAMETERS

stringPoints to a string to receive characters. 

streamPoints to the FILE structure of an open file. 

nSpecifies an upper bound on the number of characters to read. 

DESCRIPTION

The gets() function reads characters from the standard input stream, stdin, into the array pointed to by the string parameter. Data is read until a newline character is read or an End-of-File condition is encountered. If reading is stopped due to a newline character, the newline character is discarded and the string is terminated with a null character. 

The fgets() function reads characters from the data pointed to by the stream parameter into the array pointed to by the string parameter. Data is read until the n-1 characters have been read, until a newline character is read and transferred to string, or until an End-of-File condition is encountered. The string is then terminated with a null character. 

NOTES

AES Support Level:
Full use

RETURN VALUES

If the end of the file is encountered and no characters have been read, no characters are transferred to string and a null pointer is returned. If a read error occurs, a null pointer is returned. Otherwise, string is returned. 

RELATED INFORMATION

Functions: clearerr(3), feof(3), ferror(3), fileno(3), fopen(3), fread(3), getc(3), getwc(3), getws(3), puts(3), putws(3), scanf(3)

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