The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
move the last word to begining of next line - SED baskar Shell Programming and Scripting 4 02-15-2008 09:28 AM
Perl how to move pointer to previous line in a txt file? tqlam Shell Programming and Scripting 5 01-27-2008 02:24 PM
confusion (file pointer and file descripter) johnray31 UNIX for Dummies Questions & Answers 1 08-16-2006 12:59 AM
file pointer bankpro High Level Programming 1 02-20-2006 07:50 AM
file pointer bankpro High Level Programming 3 02-07-2006 01:10 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 03-26-2008
Registered User
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 48
Quote:
Originally Posted by shamrock View Post
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
Reply With Quote
Google The UNIX and Linux Forums
Forum Sponsor
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0