In addition to what Jochen said you might like to consider using
std::stringstream
or
std::strstream
to do the conversion. Despite being deprecated in 1998 [1]
strstream
is quite good at this sort of thing as you don't need to copy the data. Something like:
int number = 0;
std::strstream( number_string.GetString() ) >> number;
where
number_string
is a
CString
works quite well.
[1] But it still hasn't been removed from the standard, probably 'cause people like me like it around for extracting data from fixed size buffers.