cstring to integer or vice versa in visual c

Status
Not open for further replies.

bmwcoupe

Member level 2
Joined
May 19, 2006
Messages
51
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Activity points
1,625
cstring to int mfc

hi
i would like to know in MFC :
i have a CSTRING type variable which contains integer data
i want to convert it to a int type variable
and how do i do the opposite convert var from integer to cstring ?

10x alot !
 

cstring to integer

Hello bmwcoupe,

it is example for simple realization:

CString str;
str = "10 20"; // put two number as string

int i = atoi((LPCSTR)str); //get the first number (i=10)
str.Delete(0,3); //cut 3 first characters
i = atoi((LPCSTR)str); //get the second number (i=20)


Really you must find start position of each number in string before atoi processing.


Regards,
Igor Shakirov
www.cv.tom.ru
 

mfc cstring to integer

10x

i have already succeeded myself
i use like this : double area = atof(m_length)
or vice versa m_EditQuantity.Format("%d", Quantity);

but does someone can help me in something else :
i made SPIN BUTTON and i changed the counting base to SetBase(16)
but when i start to press up/down i see 0x0001, 0x0001F like this.........
but i want only the 01,1F
do i need to change it to char or somethnig , how can i do it ?
10x.
 

cstring to integer mfc

u can use sscanf function also
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…