Rewind file offset

Discussion in 'C Programming' started by Kuhl, Apr 10, 2009.

  1. Kuhl

    Kuhl Guest

    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.
     
    Kuhl, Apr 10, 2009
    #1
    1. Advertising

  2. In article <>,
    Kuhl <> wrote:
    >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().
     
    Kenny McCormack, Apr 10, 2009
    #2
    1. Advertising

  3. Kenneth Brody wrote:
    > Richard wrote:
    >> Joe Wright <> writes:

    > [...]
    >>> lseek() and read() are POSIX, not C. Read up on the following..

    >>
    >> Of course they are C. Don't talk such utter nonsense.

    >
    > 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.
     
    Martin Ambuhl, Apr 10, 2009
    #3
  4. In article <gro7uf$4q3$>,
    Martin Ambuhl <> bleated:
    ....
    >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.
     
    Kenny McCormack, Apr 11, 2009
    #4
  5. Kuhl

    Richard Bos Guest

    (Kenny McCormack) wrote:

    > Martin Ambuhl <> bleated:
    > ...
    > >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.


    What a pathetic little lie, Kenny.

    Richard
     
    Richard Bos, Apr 13, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    2,446
  2. Lance Riedel

    Translated Offset to Source Offset

    Lance Riedel, Oct 14, 2003, in forum: XML
    Replies:
    2
    Views:
    525
    Patrick TJ McPhee
    Oct 15, 2003
  3. Rajorshi  Biswas
    Replies:
    3
    Views:
    389
    Rajorshi Biswas
    Jul 20, 2006
  4. Alan Davies
    Replies:
    7
    Views:
    237
    Alan Davies
    Nov 27, 2003
  5. Roy Smith
    Replies:
    4
    Views:
    316
    Roy Smith
    Jan 27, 2013
Loading...

Share This Page