What's wrong with this???
Can somebody please explain me what's wrong with this code???
getline() here supposed to read a whole line at a time.... right...???
but doesn't do anything... s1 doesn't have any value when you feed it a whole line...
s reads a word terminated by '\0'... that's fine but s1 doesn't ...
<code>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
cout << "Enter a word:" << endl;
string s, s1;
cin >> s;
cout << "You Entered " << s << '\n';
cout << "Enter a sentence: \n";
getline(cin, s1);
cout << "You Entered " << s1 << '\n';
return 0;
}
</code>
Thanks
RamBUS.net
I'm using Visual Studio 6.