1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <stdio.h>
#include <stdlib.h>

int main(int argc, const char *argv[]) {
    FILE* fp = fopen("abc.txt", "r");
    char ch = '\0';
    //while(ch = fgetc(fp)) {  // BAD
    while(ch != EOF) {
        ch = fgetc(fp);
        if(ch != EOF) {
            printf("The character was '%c'\n", ch);
        }
    }
    fclose(fp);
    return EXIT_SUCCESS;
}

© Copyright 2016 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.