QP School

Full Version: File pointers and streams in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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);
}