wfstream

This is a discussion on wfstream within the C++ Programming forums, part of the General Programming Boards category; hi, i'm trying to use the wfstream version of fstream, but its doing something wierd i don't understand: Code: #include ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    50

    wfstream

    hi,

    i'm trying to use the wfstream version of fstream, but its doing something wierd i don't understand:

    Code:
    #include <MyFile.h>
    #include <fstream>
    
    using namespace std;
    
    bool MyFile::writeFile(const unsigned short* path)
    {
    wfstream file;
    file.open(path, ios::out);
    
    //checks file is open, writes some variables out with <<
    
    file.close();
    
    return true;
    
    }
    when i compile, i get the following compiler error:
    Code:
    error C2664: 'void __thiscall std::basic_ofstream<unsigned short,struct std::char_traits<unsigned short> >::open(const char *,int)' : cannot convert parameter 1 from 'const unsigned sh
    ort *' to 'const char *'
    i'm not sure whats going on there, but it looks like the open member of wfstream takes a char* parameter instead of a unsigned short* ? How is that supposed to make sense !?

    Any explanations would be appreciated.

    (using winXP and vc++ 6)

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,674
    open() always takes a char* C-string.

    The "wide" stream inserters and extractors simply interpret char* and short* as unicode strings.

    gg

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    50
    ah... i got the wrong end of the stick somehow i think.

    back to C style io then!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21