C fputs

C fputs function is implemented in file related programs for writing string to any particular file.

Syntax:
int fputs(const char *str, FILE *stream)
Example:
#include<stdio.h> 
int main()
{
FILE *fp;
fp = fopen("fileName.txt","w");

fputs("This is a sample text file.", fp);
fputs("This file contains some sample text data.", fp);

fclose(fp);
return 0; 
}

In this function returns non-negative value, otherwise returns EOF on error.


Scroll Back to Top