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.


int fputs(const char *str, FILE *stream)


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

    return 0; 

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