Ahm, I take it back - getline() for strings appears to NOT be able to limit the string - I don't quite know how you'd do that.
--
Mats
Printable View
Ahm, I take it back - getline() for strings appears to NOT be able to limit the string - I don't quite know how you'd do that.
--
Mats
matsp, on the link you gave, it says...
But I thought string wasn't a keyword? O_OCode:string s;
getline( cin, s );
cout << "You entered " << s << endl;
And Im afraid I did not understand your solutions to the problem (pheres and matsp)...
That reference implicitly assumes that the std namespace is in use, so string is actually std::string, just as getline, cin, cout and endl are actually std::getline, std::cin, std::cout and std::endl respectively. Either way they are not keywords, but names from the std namespace.
Thanks for that one o.o
I wonder how I can do away with the recursion here, though...?
Instead of
as you are doing now, doCode:get_email()
{
get input;
if(error)
{
get_email(); // <- recursion. You are calling A from inside A again and again, as long
// as invalid formats are entered
}
}
Code:
bool success = false;
do
{
get_email();
if(error)
{
success = false;
}
else
{
success = true;
}
}
while(! success) // <- now call A in a loop, till a valid address is gotten