I don't know why my program is reading only first line. The text.file has 2 lines actually.
The first line is printing.
But the second line is not printing
The output is always:
The first line is printing.
Here is my program:
Code:
#include<stdio.h>
int main(){
FILE *in=fopen("satu.txt","rt");
char hello[100];
fgets(hello,60,in); /*what is the use of in? Why writing in this format?*/
printf("first line of \"text.txt\": %s", hello);
fclose(in); /*closing file*/
return 0;
}
I am now learning how to read from a file. But here I don't know what is the use of in . I found this in a tutorial. If I delete it, the program doesn't work.