C fputs

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

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; 

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

Scroll Back to Top