![]() |
VOOZH | about |
fputs() is a function declared in stdio.h header file. It is used to write the contents of the file. The function takes 2 arguments. The first argument is a pointer to the string which is to be written and the second argument is the pointer of the file where the string is to be written. It returns 1 if the write operation was successful, otherwise, it returns 0. fputs() writes a single line of characters in a file.
Syntax-
fputs(const *char str, FILE *fp); where str is a name of char array that we write in a file and fp is the file pointer.
Example-
Input- str1 = “geeksforgeeks”, str2 = “gfg”
Output- The output file will consist of two lines:
geeksforgeeks
gfg
Below is the C program to implement the fputs() function-
Output-