Hi all,

I have problem regarding feof(). For example, I have
two files (data1.txt and data2.txt).
data1.txt :
1 2

data2.txt:
1 2
1.0 2.0 3.0
4.0 5.0 6.0
7.0 8.0 9.0

Here is the code that I use to read data1.txt
===============
...
while(!feof(fp)){
    fscanf(fp,"%d %d",&n,&m)
    printf("%d %d",n,m);
}
.....
===============

And for the second file
===============
...
while(!(feof(fp)){
    fscanf(fp,"%d %d",&n,&m);
    print("%d %d",n,m)
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
             fscanf(fp,"%lf",a[i][j]);
       }
    }
}
....
=================

For the first code, I get what I want. It prints
1 2
But for the second code, it prints twice 
1 2
1 2
It seems while() accesses data2.txt twice.

I wonder where the problem is. Thanks for any
explanations.

Cheers,
Titi


      
____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


Reply via email to