Thread: pwrite and pread

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    1

    pwrite and pread

    Hello guys, I am using pwrite and pread to read and save data to a file, but every time I close the file and reopen it, all the information is gone. Do I have to do something to actually save the info on the file, so I can reopen the file and see the info again there?

    Thanks

  2. #2
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    In the future, please provide code.

    I'll assume you're opening the file with "w", and if so, that will truncate the file. Don't open with "w" if you don't want the file destroyed.

    If that's not the case, then you'll probably want to post compilable code that demonstrates the problem.

    Edit: Since you say you're using pwrite() and pread(), I shouldn't assume you're using fopen(), but instead open(). In which case my response would be "maybe you're using O_TRUNC", even though that seems unlikely, so it'd be even more useful for you to post code.
    Last edited by cas; 04-21-2012 at 04:05 PM.

Popular pages Recent additions subscribe to a feed