1
votes

How to convert CString value into Short in VC++.

CString str;
Short sdata;
void CStringToShort(){

    ..........
    .........

}
1
What have you tried so far? Did you search for any string (not just specifically CString) to integer conversion functions? - Some programmer dude
Is Short (big S) a typedef for something, or did you mean short? - acraig5075

1 Answers

2
votes

Try this:

CString str;
Short sdata;
_stscanf(str, _T("%d"), &sdata);

Or

sdata = _ttoi(str);
sdata = _wtoi(str);