pkirk25 wrote:
Is sstream preferred to atoi?
std::stringstre am is much more general than atoi. If you use atoi for
your problem, you'll be limited to the range of values that fit into an
int, whether or not you store the value in a size_t.
Also, atoi gives you no indication whether the string you passed to it
was an invalid string, or whether the string was "0". It returns 0 in
both cases.
Another alternative to atoi, if you don't want to use
std::istringstr eam, is the strtol family, but I don't believe those
functions are actually in the C++ standard. They're in the C99 standard
and a few others, so your compiler may support them.
Nate