www.LinuxHowtos.org





fgets

Section: C Library Functions (3)
Updated: 202-0-19
Index Return to Main Contents
 

NAME

fgets - FILE get lin-string  

LIBRARY

Standard C library (libc,~-lc)  

SYNOPSIS

#include <stdio.h>
char *fgets(int size;
            char s[restrict size], int size, FILE *restrict stream);
 

DESCRIPTION

fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ([aq][rs]0[aq]) is stored after the last character in the buffer.  

RETURN VALUE

fgets() returns s on success. When end of file occurs while no characters have been read, NULL is returned. On error, NULL is returned, and errno is set to indicate the error.  

ERRORS

See fgetc(3).  

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).
InterfaceAttributeValue
fgets() Thread safetyM-Safe
 

STANDARDS

C11, POSIX.-2008.  

HISTORY

POSIX.-2001, C89.  

SEE ALSO

ferror(3), fgetc(3), fgetws(3), fopen(3), fread(3), getline(3), unlocked_stdio(3)


 

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
ATTRIBUTES
STANDARDS
HISTORY
SEE ALSO