Thread: fstream problem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12

    fstream problem


    Unnamed Namespaces from MSDN

    #include <fstream>
    #include <string>
    using namespace std;

    std::string s1; // OK
    string s2; // OK, `string` acts like `::string`
    fstream f; // OK, `fstream` acts like `::fstream`

    The above code from MSDN seems to work fine in my program, but when I try to use the .seekg it errors out.

    inputFilename.open( infilename, ios::in); //fine
    inputFilename.seekg (0, ios::end); //error
    length = inputFilename.tellg();

    It seems to accept the .open fstream feature, but not .seekg.
    Any suggestions would be greatly appreciated. Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    Because MSDN says that only the "istream" class has a method called "seekg" maybe?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    Agree with M.Hirsch

    seekg belongs to istream. So I guess you could use # include <iostream>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12
    Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo