fputs() in C Programming
fputs( ) is basically used to write string data and information in stream(file).
![]() |
| fputs() in C Programming |
Through this article we will be going to discuss fputs( ) function of C in detail in which we will cover following topics.
- fputs( ) function in c
- header file for fputs( ) function in c
- return value of fputs( ) function in c
- fputs( ) function in c syntax
- fputs( ) function in c program
fputs( ) function in C
The fputs( ) function is nothing but, it is a standard library function of C and it also called file handling function which is basically used to write string in the stream(file).
Header file for fputs( ) function in C
This file function is define in <stdio.h> which is stand for standard input-output header file.
Return value of fputs( ) function in C
fputs( ) function return last character on success and if error occur than it returns End of File(EOF).
Syntax of fputs( ) function in C
int fputs(const char *str , FILE *pointer):
Example of fputs( ) function in C
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fptr;
char str[80],j;
fptr=fopen("test.txt", "w");
printf("Enter the text \n") ;
printf("To stop entering press Ctrl+d");
while (gets(str)!=NULL)
fputs(str,fptr);
fclose(fptr);
return 0;
}
Conclusion
fputs( ) is basically used to write string data and information in the sream(file).

