C fputs() function is implemented in file-related programs for writing strings to any particular file. This tutorial guides you on how to use the fputs() function in the C program.

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; 
}

This function returns a non-negative value, otherwise returns EOF on error.