Computer Science Canada input of strings in c++ |
Author: | halo3d [ Sat Nov 11, 2006 8:15 pm ] | ||
Post subject: | input of strings in c++ | ||
hi, i m currently on the file i/o part and then i notced something. the cin doesnt accept strings why is that e.g.
the error i get is .. no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) any way to get around that? im trying so that what ever string user enters is saved to a file.. the saving of predefined strings works but not when i try to input something as a string.. help would be appreciated ![]() |
Author: | wtd [ Sat Nov 11, 2006 8:22 pm ] |
Post subject: | |
Works fine for me. Please post all of your code. |
Author: | halo3d [ Sat Nov 11, 2006 8:38 pm ] | ||||
Post subject: | |||||
Library.h has this...
test.cpp, the main file, has this
the whole error is... ------ Build started: Project: test, Configuration: Release Win32 ------ Compiling... test.cpp test.cpp(5) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) test.cpp(6) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) Build log was saved at "file://d:\C++\test\Release\BuildLog.htm" test - 2 error(s), 0 warning(s) im using visual .net 2003 ---------------------- Done ---------------------- Build: 0 succeeded, 1 failed, 0 skipped |
Author: | bugzpodder [ Sat Nov 11, 2006 9:42 pm ] |
Post subject: | |
have a #include<string> somewhere |
Author: | halo3d [ Sat Nov 11, 2006 10:03 pm ] |
Post subject: | |
omg i cant believe i keep forgetting that |
Author: | wtd [ Sat Nov 11, 2006 10:59 pm ] | ||||||
Post subject: | |||||||
If you desire a challenge, I suggest trying to figure out why you might want:
To become:
Because then you can have, for instance:
|