input : ha ha haCode:#include <iostream> using namespace std; void input_string( string &s) { cout << "input string s = "; cin >> s; cout << s; }
why output: ha ???
I want output ha ha ha. help me problem this?
input : ha ha haCode:#include <iostream> using namespace std; void input_string( string &s) { cout << "input string s = "; cin >> s; cout << s; }
why output: ha ???
I want output ha ha ha. help me problem this?
The stream (cin) only copies characters until it hits whitespace, when using the operators. Maybe you want:
Code:std::getline(cin, s);
Last edited by Dae; 09-28-2009 at 02:59 AM. Reason: oops, posted c-style string getline
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
error
-No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Sorry, wrong getline, try this one:
getline - C++ Reference
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
good. thanks very much