Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
int main() {
FILE *fp;
char ch;
fp = fopen("data.txt", "r");
if (fp == NULL) {
printf("Error: File could not be opened!\n");
return 1;
}
while ((ch = fgetc(fp)) != EOF) {
putchar(ch);
}
if (ferror(fp)) {
printf("\nError while reading file!\n");
}
fclose(fp);
printf("\nFile closed successfully.\n");
return 0;
}Coding works best on desktop or with an external keyboard.