C language - fgets

อ่านข้อมูลจากไฟล์ทีละบรรทัด
/* fgets exmaple */

#include <stdio.h>

#define myfile "control"

int main() {
    FILE * fp;

    fp = fopen(myfile, "r");
    if (fp == NULL)
        perror("Error opening file");
    else {
        char mystring[100];
        while (fgets(mystring, sizeof(mystring), fp)) {
            printf(mystring);
        }
        fclose(fp);
    }
    return 0;
}
ที่มา: cplusplus