Thread: Problems with fstream, one variabile for write and read

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    14

    Problems with fstream, one variabile for write and read

    I use a fstream variabile to open a file in write and read mode.

    Code:
    fstream file;
    file.open("filepath", ios::in | ios::out | ios:: binary);
    What's the difference between using seekg or seekp?
    There's really two different pointers or there's only one?

    Why if i read things, write things then move the pointer to the beginning to overwrite data (using for example file.seekp(0)) it writes the data to the end of the file?

    I used seekg and seekp either for moving read and write pointers (if there's really two), i also tried to use only seekg.. ah and everytime i write something, before reading or moving the pointer, i flush the fstream.
    Last edited by Smjert; 02-03-2009 at 09:54 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 07-24-2002, 06:33 AM
  2. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  3. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  4. I/O Problems - fstream
    By mol in forum C++ Programming
    Replies: 17
    Last Post: 10-16-2001, 03:50 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM