An alternative to sscanf is to use std::stringstream. However you need to convert CString to std::string and vice versa
Here a snippet from
Codeguru how to do just that, and then I'll tell you how to use StringStream
CString cs ("Hello");
// Convert a TCHAR string to a LPCSTR
CT2CA pszConvertedAnsiString (cs);
// construct a std::string using the LPCSTR input
std::string strStd (pszConvertedAnsiString);
And now comes the stringstream part. Here's how I would do it.
//here's the std::string
std::string ss("10");
//use the string as an input stream
istringstream astream(ss,ios::in);
int val;
//extract the value from the input stream
astream>>val;
val -= 1;
//now use the string as an output stream
ostringstream os(ios::out);
//extract the value
os<<val;
//create a string out of it
string ass = os.str();
//convert your std::string to a CString
CString final(ass.c_str());