Home › Forums › C Programming › Help – file reading › Re: Re: Help – file reading
March 26, 2009 at 7:10 pm
#3535
msaqib
Participant
The code
1 | while (fgets(line,100,infile)!=NULL) |
reads the file and function fgets() reads the file line by line. So when the program reads first line, it skips the first line of records which is
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%) Final(40%)
and is done by this code:
1 2 3 4 | if(x==1)<br /> {<br /> <br /> } |
And you read all the marks and data in else part of the program.
1 2 3 4 5 6 | else{<br /> i=0;<br /> while( fscanf(infile,"%d %s %d %d %d %d %d %d",&no<i>,matrix</i><i>, &quiz_1</i><i>, &quiz_2</i><i>, &quiz_3</i><i>, &project</i><i>, &midT</i><i>, &final</i><i>) !=EOF)<br /> printf("%d %s %d %d %d %d %d %dn",no</i><i>, matrix</i><i>, quiz_1</i><i>, quiz_2</i><i>, quiz_3</i><i>, project</i><i>, midT</i><i>, final</i><i>);<br /> i++;<br /> }</i> |