Hello All,
Can any one help me in this file read problem.
#include <stdio.h>
int main()
{
FILE* fp = fopen("TITLE.mx 2","rb");
char h[100];
while(fscanf(fp ,"%[^\r\n]",h) != EOF)
{
fprintf(stdout, "%s",h);
if((fscanf(fp," %[\r\n]",h) == EOF)) //dummy
break;
}
fclose(fp);
return 0;
}
it goes into an infinite loop.
Am i eating up the EOF?
here while(fscanf(fp ,"%[^\r\n]",h) != EOF)?
how to avoid it?
Thanks in advance.
Regards,
Naren.
Can any one help me in this file read problem.
#include <stdio.h>
int main()
{
FILE* fp = fopen("TITLE.mx 2","rb");
char h[100];
while(fscanf(fp ,"%[^\r\n]",h) != EOF)
{
fprintf(stdout, "%s",h);
if((fscanf(fp," %[\r\n]",h) == EOF)) //dummy
break;
}
fclose(fp);
return 0;
}
it goes into an infinite loop.
Am i eating up the EOF?
here while(fscanf(fp ,"%[^\r\n]",h) != EOF)?
how to avoid it?
Thanks in advance.
Regards,
Naren.
Comment