{}
CODE VISUALIZER
Learn DSA the way it should be — with step-by-step code visualization.
Try now!
CODE VISUALIZER
Learn DSA with step-by-step code visualization.
Try now!
run-icon
main.c
#include <stdio.h> int main() { FILE *fp; // Open the file in write mode fp = fopen("log.txt", "w"); // Check if file opened successfully if (fp == NULL) { printf("❌ Error opening the file.\n"); return 1; } // Write 5 lines into the file for (int i = 1; i <= 5; i++) { fprintf(fp, "This is line number %d\n", i); } // Close the file fclose(fp); printf("✅ log.txt created successfully with 5 lines.\n"); return 0; }
Output