Well, this stinks....I'm able to user ostringstream to wreite data to a file but when i read it back, Dev C++ gives me these errors:
Code:Compiler: Default compiler Building Makefile: "F:\Projects\Makefile.win" Executing make... make.exe -f "F:\Projects\Makefile.win" all g++.exe -c User.cpp -o User.o -I"F:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"F:/Dev-Cpp/include/c++/3.4.2/backward" -I"F:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"F:/Dev-Cpp/include/c++/3.4.2" -I"F:/Dev-Cpp/include" User.cpp: In member function `bool User::loadUserFile(const char*)': User.cpp:54: error: ambiguous overload for 'operator>>' in '((User*)this)->User::UserDataIn >> ((std::string*)this)->std::basic_string<_CharT, _Traits, _Alloc>::c_str [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]()' F:/Dev-Cpp/include/c++/3.4.2/istream:687: note: candidates are: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*) [with _Traits = std::char_traits<char>] <near match> F:/Dev-Cpp/include/c++/3.4.2/istream:692: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*) [with _Traits = std::char_traits<char>] <near match> User.cpp:55: error: ambiguous overload for 'operator>>' in '((User*)this)->User::UserDataIn >> (((std::string*)((User*)this)) + 4u)->std::basic_string<_CharT, _Traits, _Alloc>::c_str [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]()' F:/Dev-Cpp/include/c++/3.4.2/istream:687: note: candidates are: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*) [with _Traits = std::char_traits<char>] <near match> F:/Dev-Cpp/include/c++/3.4.2/istream:692: note: std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*) [with _Traits = std::char_traits<char>] <near match> make.exe: *** [User.o] Error 1 Execution terminated
this is how i'm reading the data:
Also how would i make it so when u typed the password u'd get this: "*"?Code:bool User::loadUserFile(const char* filename) { char UBuff[256]; sprintf(UBuff,"%s.user",filename); UserFileIn.open(UBuff,ios_base::binary ); if(UserFileIn.is_open() ) { UserDataIn >> UserName.c_str(); UserDataIn >> Password.c_str(); UserFileIn.read((char*)&UserDataIn,sizeof(UserDataIn)); if(UserFileIn.is_open() ) { UserFileIn.close(); } return true; } else { return false; } return true; }



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.