#include <stdio.h>
int main() {
FILE *filePointer;
char filename[100];
char content[1000];
// Step 1: Get the filename from the user
printf("Enter the filename: ");
scanf("%s", filename);
// Step 2: Open the file in read mode
filePointer = fopen(filename, "r");
// Step 3: Check if the file opened successfully
if (filePointer == NULL) {
printf("File not found or could not be opened.\n");
return 1; // Exit the program with an error code
}
// Step 4: Read the content of the file
while (fgets(content, sizeof(content), filePointer) != NULL) {
// Step 5: Print each line of the file content
printf("%s", content);
}
// Step 6: Close the file
fclose(filePointer);
return 0; // Exit the program successfully
}