I would like to know how to convert a Cstring into a int.
Thanks a lot
Philippe.
Printable View
I would like to know how to convert a Cstring into a int.
Thanks a lot
Philippe.
int value;
sprintf(value, "%i", strText);
use the function atoi(). (ascii to int)
for example:
CString string = "40";
int zahl = atoi(string); // converts string to int
...this should help you.
Danke sehr Rocky.
CString l_str;
int l_iVar;
l_str.Format("%d", l_iVar);
hope this should help you.
Regards,
Sanjay
[email protected]
int sprintf( char *buffer, const char *format [, argument] ... );
This is the prototype for sprintf function.
So your the code below won't compile at all.
Also, you are not doing exactly what the question is.
int value;
sprintf(value, "%i", strText);
use atoi(CString ) to convert a CString object to an integer....
Thanks lot,
Srini
you can use function strcpy(CString, char) to convert the Cstring to character first, and then use function atoi(*char ) to convert the character to int.
CString---->Character----->interger
email me to let me know your progress
ty