fgets

Syntax

char * fgets(char * s, int n, int * fileptr)

Arguments

s
Pointer to a string which will contain the bytes read.
n
Maximum number of bytes to read.
fileptr
Pointer to a file opened using fopen.

Return

A pointer to string s if succesful, otherwise NULL.

Description

Reads upto n number of bytes from the file referenced by fileptr into string s.
This function will add a NULL to the end of the string, so make sure to make n less than the memory allocated for string s.

Also see

fopen, fputs, fgetc, fread

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.