|
-
May 19th, 1999, 02:13 PM
#1
How to convert a Cstring into a int ?
I would like to know how to convert a Cstring into a int.
Thanks a lot
Philippe.
-
May 19th, 1999, 02:25 PM
#2
Re: How to convert a Cstring into a int ?
int value;
sprintf(value, "%i", strText);
-
May 19th, 1999, 02:27 PM
#3
Re: How to convert a Cstring into a int ?
use the function atoi(). (ascii to int)
for example:
CString string = "40";
int zahl = atoi(string); // converts string to int
...this should help you.
-
May 19th, 1999, 02:33 PM
#4
Re: How to convert a Cstring into a int ?
-
May 20th, 1999, 02:52 AM
#5
Re: How to convert a Cstring into a int ?
CString l_str;
int l_iVar;
l_str.Format("%d", l_iVar);
hope this should help you.
Regards,
Sanjay
[email protected]
-
May 20th, 1999, 05:52 AM
#6
Re: How to convert a Cstring into a int ?
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);
-
May 20th, 1999, 08:24 AM
#7
Re: How to convert a Cstring into a int ?
use atoi(CString ) to convert a CString object to an integer....
Thanks lot,
Srini
-
May 21st, 1999, 04:43 AM
#8
Re: How to convert a Cstring into a int ?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|