[Tuxcpprogramming] Converting string to int in safe fashion

Mark Phillips mark at austrics.com.au
Tue Jul 17 12:27:04 UTC 2001


Suppose I have a string containing an integer,
eg myString=="271".  To convert this into an integer,
one way would be using the code:

istringstream iss(myString);

But what if there was an error, eg myString=="27dog1"
so that it couldn't convert to an integer properly?

More information about the tuxCPProgramming mailing list