
03-26-2008
|
|
Registered User
|
|
Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 48
|
|
Quote:
Originally Posted by shamrock
If you had followed the reply from jim mcnamara's post then you wouldn't be asking this question.
|
Hi Shamrock,
i went thro Jim post.
In that he mentioned,
Quote:
/* change this */
i= ftello(fh);
/* to this */
i++;
|
to put the above code in the below program,
Quote:
void read_line(void *fh, double *input_re, double *input_im){
double a, b;
char s[50];
int n;
int i=0;
if ( fgets(s, sizeof(s), fh) != NULL){
i= ftello(fh);
}
printf("FILE Current Pos: %d\n ", i);
printf("IMP: %s ", s);
sscanf(s,"%lf %lf",&a,&b);
*input_re = a;
*input_im = b;
}
else{
rewind(fh);
}
}
|
As he said, if we change to i++ and it will be giving the no of lines. Accepted..
But while considering the current thread, how can we put the no of bytes in fseek fn by having this code.
Say, if we are saying 10 th line, (i.e) pos=10 how fseek(fh,pos,SEEK_SET) will understand that position is line count. Normally this function will consider pos is equal to byte count no?, if my understanding is correct?Regards,
Ramkrix
|
|
Google The UNIX and Linux Forums
|