write array of char to file in c

Solutions on MaxInterview for write array of char to file in c by the best coders in the world

showing results for - "write array of char to file in c"
Angela
28 Jan 2018
1// Char arrays are declared like so:
2char array[] = "YOUR TEXT HERE";
3
4// Open a file for writing. 
5// (This will replace any existing file. Use "w+" for appending)
6FILE *file = fopen("filename", "w");
7
8int results = fputs(array, file);
9if (results == EOF) {
10    // Failed to write do error code here.
11}
12fclose(file);