i am bit confused about this code, why does the below while loop is
contineous
how can i come out of the file.
i am using linux machine
char ch;//char varaible
FILE *fp; // file pointer
fp=fopen("file" ,"r");
while(fp!=EOF)// here i am just reading character by character and
printing to display
{
fscanf(fp,&ch);
printf("%c",ch) ;
}
problem is:: At end ,file pointer is pointing to last character and it
is holding that because of this
the while condition is true
so how can i come out of loop
contineous
how can i come out of the file.
i am using linux machine
char ch;//char varaible
FILE *fp; // file pointer
fp=fopen("file" ,"r");
while(fp!=EOF)// here i am just reading character by character and
printing to display
{
fscanf(fp,&ch);
printf("%c",ch) ;
}
problem is:: At end ,file pointer is pointing to last character and it
is holding that because of this
the while condition is true
so how can i come out of loop
Comment