#include #include int main() { char ch, filename[25]; FILE *fp; printf("Enter file name\n"); gets(filename); fp = fopen(filename, "r"); // read mode if (fp == NULL) { printf("Error while opening file.\n"); exit(1); } printf("The contents of file\n", filename); while((ch = fgetc(fp)) != EOF) printf("%c", ch); fclose(fp); return 0; }