Thread: seekg() problem

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    11

    seekg() problem

    Hi, people.

    I need to write data in file, but not from the file begining.
    After operating with seekg() to move file pointer, the compiler brings such message: "....'struct std:fstream' has no member named 'seekg' "


    *code*

    ofstream write;

    write.seekg(offset*6, ios::beg);

    ********

    What i did wrong?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    XXXg functions are for streams that can 'get' values, and XXXp functions for those that can 'put' values. In other words, istream's fall in the first category, ostreams in the second, and iostreams in both.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And just to clarify a bit, the reason for all this is that some streams (such as iostreams) support independent read/write 'file' pointers. It probably would have been more logical to simply provide a 'seek' wrapper function for istream/ostream, of course, but that's just the way they decided to do things.

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    11
    If counting my bad english, i understand first reply . Frankly speaking i expect to see a few lines of correct code. )))

  5. #5
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Quote Originally Posted by Rustik_ View Post
    If counting my bad english, i understand first reply . Frankly speaking i expect to see a few lines of correct code. )))
    Oh, you expect to see a few lines of correct code, just to, you know, speed things up for you?

    You know what we expect ? We expect people to be self-sufficient and capable of doing research on their own. If you had looked up the ofstream class and its method on a site such as C++ Reference, you'd have found that there is no member function called seekg(). Oh wait, the error tells you that already.

    What could possibly tell you why there isn't one? Hmm. That's a tough one.

    Please, don't come on these boards asking a question that reeks of a general lack of self-sufficiency, then demand something more when you do get help.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  6. #6
    Registered User
    Join Date
    Aug 2009
    Posts
    11
    2IceDane:

    hope u know place to put in all your self-sufficiencies

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by Rustik_ View Post
    2IceDane:

    hope u know place to put in all your self-sufficiencies
    No need to be crass about it - IceDane's comment was to-the-point and perfectly reasonable. If you can't respond in a civil manner then I'd recommend seeking help elsewhere.

    It isn't always easy to take criticism from others, but if you can learn to deal with it I think you'll find that an honest assessment, however critical it may be, is more often than not a valuable thing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM