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
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
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.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
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