Rewind file offset

K

Kuhl

Hi, I am programming with C in Linux. During reading a file, I need to
rewind the file offset backwards sometimes. I learned that lseek()
function can check the offset. But I did not find a way to set the
offset. I tried using read(fd, databuf, -5), but the offset does not
go back. What's the correct way to rewind the file offset? Thanks.
 
K

Kenny McCormack

Hi, I am programming with C in Linux. During reading a file, I need to
rewind the file offset backwards sometimes. I learned that lseek()
function can check the offset. But I did not find a way to set the
offset. I tried using read(fd, databuf, -5), but the offset does not
go back. What's the correct way to rewind the file offset? Thanks.

With lseek().
 
M

Martin Ambuhl

Kenneth said:
Strange... My system's manual tells me that lseek() and read() are
POSIX (along with some other non-C standards like "SVr4" and "BSD 4.3").

And now you know why Richard <no last name> posts anonymously: to post
nonsense with no consequences. For some strange reason there are people
who deny that "troll" is appropriate for this anonymous poster who posts
garbage and snipes at those who know better C than he does.
 
K

Kenny McCormack

Martin Ambuhl said:
And now you know why Richard <no last name> posts anonymously: to post
nonsense with no consequences. For some strange reason there are people
who deny that "troll" is appropriate for this anonymous poster who posts
garbage and snipes at those who know better C than he does.

Yes. We see that you do this all the time.

But we tolerate you. It is a free country.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top