Click to See Complete Forum and Search --> : Converting CString to int.


Steve Charlewood
October 14th, 1999, 08:13 AM
How can I convert a CString, which has extracted the writing on a button (always a number in my app), into an ineteger that I can pass to a function taking integer values?

thanks

steve

Thomas Ascher
October 14th, 1999, 08:25 AM
Hi, simply use atoi function.

CString str = "123";
int n = atoi(str); // CString is casted automatically to LPCTSTR by the CString operator LPCTSTR

October 14th, 1999, 08:34 AM
Hi,
use operator LPCTSTR ()for converting CString object.Then use atoi(LPCTSTR).
Hope this helps you.

Manash