MicrOS
fgets.c File Reference
#include "../stdio.h"

Functions

char * fgets (char *str, int num, FILE *stream)
 Get string from stream. More...
 

Function Documentation

◆ fgets()

char* fgets ( char *  str,
int  num,
FILE stream 
)

Get string from stream.

Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first.

Parameters
strPointer to an array of chars where the string read is copied.
numMaximum number of characters to be copied into str (including the terminating null-character).
streamPointer to a FILE object that identifies the stream to be closed.
Returns
On success, the function returns str. If the end-of-file is encountered while attempting to read a character, the eof indicator is set. If this happens before any characters could be read, the pointer returned is a null pointer.