Hi guys i am wirting a c programme here and i am trying to print two lines from a text file at a time the problem is that when on the last line if the lines are odd, 3 lines 5 lines. It will print the last line twice.I cant find the comparison of if function for thsi particualr question. is it a bool? I am trying ferror(file) currently
    FILE *file;
    printf("Hello!\n");
    printf("Please input file name(without.txt):\n");
    scanf("%s", input);
    strcat(input,".txt");
    file = fopen( input , "r" );
    while(!(feof(file)))
    {
        for(i=0; i<2; i++){
        **if(feof(file)==ferror(file))**
        {
            printf("File ended");
                return 0;
        }
        else
        {
            fgets(return_char, 200, file);
            printf("%s\n", return_char);
        }
    }
    }
Example of input :
i have a cat
i have a dog
i have a cow
Expected output :
first round
i have a cat
i have a dog
second round :
i have a cow
Current output : first round :
i have a cat
i have a dog
second round :
i have a cow
i have a cow
 
     
    