#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;
}