C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - General Questions (Q.No. 9)
9.
Out of fgets() and gets() which function is safe to use?
gets()
fgets()
Answer: Option
Explanation:
Because, In fgets() we can specify the size of the buffer into which the string supplied will be stored.
Discussion:
3 comments Page 1 of 1.

Kumar said:   1 decade ago
char *fgets(char *str, int n, FILE *stream).

Parameters:

str -- This is the pointer to an array of chars where the string read is stored.

n -- This is the maximum number of characters to be read (including the final null-character). Usually, the length of the array passed as str is used.

stream -- This is the pointer to a FILE object that identifies the stream where characters are read from.

Raghavendra said:   8 years ago
What is buffer?

SagarPawar said:   8 years ago
buff means Buffer,

After fgets u can copy data to another file using fputs.

fputs(buff, ft)
Here ft is a pointer to the target file.

Post your comments here:

Your comments will be displayed after verification.