V
Vladimir Lushnikov
Hi,
I have just started learning C++ and have been trying to do simple
string manipulation. However, when calling this function:
int helloString()
{
string name;
cout << "Please enter your name:\n";
getline(cin, name);
cout << "Length of string: " << name.length() << "\n";
return 0;
}
The compiled program gives absolutely no control for the user to type
the string in, so the length of it is always zero. helloString() is
called out of main() in a switch() statement [if that knowledge helps].
So does anyone know what the problem is, and why it won't let me type
anything in befere continuing as normal?
Thanks,
Vladimir Lushnikov
I have just started learning C++ and have been trying to do simple
string manipulation. However, when calling this function:
int helloString()
{
string name;
cout << "Please enter your name:\n";
getline(cin, name);
cout << "Length of string: " << name.length() << "\n";
return 0;
}
The compiled program gives absolutely no control for the user to type
the string in, so the length of it is always zero. helloString() is
called out of main() in a switch() statement [if that knowledge helps].
So does anyone know what the problem is, and why it won't let me type
anything in befere continuing as normal?
Thanks,
Vladimir Lushnikov