07-25-2023, 01:24 PM
File pointers are used to interact with files.
FILE *file = fopen("data.txt", "r");
if (file != NULL) {
int ch;
while ((ch = fgetc(file)) != EOF) {
putchar(ch); // Output: Contents of the file
}
fclose(file);
}
FILE *file = fopen("data.txt", "r");
if (file != NULL) {
int ch;
while ((ch = fgetc(file)) != EOF) {
putchar(ch); // Output: Contents of the file
}
fclose(file);
}