|
From: <pr...@le...> - 2003-04-01 05:27:22
|
Can anyone tell me how to have string variables contain spaces? I'm using
the following code to let the user enter his name. It works fine. But the
string gets truncated at the first space that it encounters.
Hence "Jack the Ripper" gets cut short to "Jack" and "Mary Magdalene" turns
to "Mary".
Here's my code.
#include <iostream>
using namespace std;
int main()
{
string name;
cout << "Please enter your name: ";
cin >> name;
cout << "Hello " + name;
}
Regards,
Pranav Negandhi
This email is a natural product. The slight variations in spelling and
grammar enhance its individual character and beauty and are in no
way considered to be flaws or defects.
|