fputs() in C Programming | Detail

 fputs() in C Programming

fputs( ) is basically used to write string data and information in stream(file).

fputs() in C programming
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.

  1. fputs( ) function in c
  2. header file for fputs( ) function in c
  3. return value of fputs( ) function in c
  4. fputs( ) function in c syntax
  5. 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;
}

____________________________________

example of fputs in c
____________________________________

Conclusion

fputs( ) is basically used to write string data and information in the sream(file).
Post a Comment (0)
Previous Post Next Post