LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-05-2003, 07:58 PM   #1
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Rep: Reputation: 31
read from file from the beginning?


Hello

How can I force fgets (in c) to begin reading form a specific offset? to be more exact, i need to read from the beginning of the file (every time i issue a fgets command), without closing the file and reopening. So i need to reset the file read pointer somehow...

How is that done?

thanks

raven
 
Old 12-05-2003, 08:22 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You would use fseek. Take a look at the man page and if you have any questions post them.
 
Old 12-05-2003, 08:24 PM   #3
ac1980
Member
 
Registered: Aug 2003
Location: Trento, Italy
Distribution: Debian testing
Posts: 394

Rep: Reputation: 30
fseek and its happy family: visit them at "man fseek" ;-)

doh! already posted. If it was i duel i'd be in trouble!

Last edited by ac1980; 12-05-2003 at 08:25 PM.
 
Old 12-05-2003, 08:32 PM   #4
LinuxTiro
Member
 
Registered: Aug 2003
Posts: 59

Rep: Reputation: 15
use Function int fseek (FILE *stream, long int offset, int whence)
as
int fseek(FILE *stream,0,SEEK_SET);
before using fgets;

oops same happened with me.

Last edited by LinuxTiro; 12-05-2003 at 08:33 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming file names beginning with "-" prashln Linux - General 5 05-01-2010 01:47 AM
How do I write to the beginning of a file? abefroman Programming 1 06-30-2005 11:56 AM
How to add data at file beginning in C? Nad0xFF Programming 8 04-17-2005 11:48 AM
How to delete a file beginning with '-'? zoomzoom Linux - General 2 02-02-2004 10:01 AM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration