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?
Printable View
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);
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
good. thanks very much