C - File Handling - Write lines to a file


C - File Handling - Write lines to a file

CODE
#include <stdio.h> #include <string.h> int main() { char line[500]; FILE* outputFile = fopen("output.txt", "w"); strcpy(line, "This is line 1\n"); fprintf(outputFile, "%s", line); fprintf(outputFile, "%s", "This is line 2"); fclose(outputFile); return 0; }

Comments