Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting CString to int

Status
Not open for further replies.

Berras

Programmer
Feb 24, 2002
42
GB
The title says it all is there anyway to convert a CString variable into a int variable?
 
Sorry, I meant how can you turn a CString such as "hello" into a numerical value.
 
Turn a character such as "h" into a number.
 
ok... suppose that i guess that you want the ASCII value of the characters then..

CString s("hello");

cout << (int)s[0];

will output '72'

-pete
 
Cstring s;
int i=10;
s.format(&quot;%d&quot;,i);
MessageBox(s);

s now contains the value 10;

if u want to convert from string to integer
use this function
atoi() and if u want to convert from integer to string use
itoa() .. check the parameters.
ok bye
venki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top