How to convert a CString object to integer in MFC.
The simplest approach is to use the atoi() function found in stdlib.h:
CString s = "123";
int x = atoi( s );
However, this does not deal well with the case where the string does not contain a valid integer, in which case you should investigate the strtol() function:
CString s = "12zzz"; // bad integer
char * p;
int x = strtol ( s, & p, 10 );
if ( * p != 0 ) {
// s does not contain an integer
}