I was wondering if there's a way to convert a CString or a char *x[10] to a int? I know I can convert int to CString, but can it go the other way?
Thanx,
Atrus

for CString (I assume you mean Microsoft MFC CString class)

// convert from CString to int just requires typcasting the CString
CString str = "123";
int n = atoi((LPCTSTR)str);

// convert from int to CString
str.Format("%d", n);

ok so would the following statement work then?

char *str[5];
str[0] = "123";
int n = atoi((LPCTSTR)str[0]);

and yes I meant MFC CStrings... Sorry I didn't mentionthat

ok so would the following statement work then?

char *str[5];
str[0] = "123";
int n = atoi((LPCTSTR)str[0]);

you don't need to typecast character arrays -- that typecast is to convert a CString object to const char*.

char *str[5];
str[0] = "123";
int n = atoi(str[0]);
This question has already been answered. Start a new discussion instead.