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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conversion CString to int

Status
Not open for further replies.

alcyone

Programmer
Sep 6, 2000
33
Hi all,

Is there a function which converts a CString to an int? I know I could easily make one myself, but that's not my question. I cannot find a CString member function which does the job.
Thanks in advance!
 
You can do:
CString s1 = "12345";
int i1 = atoi(s1); // i1 = 12345
CString s2 = "123a45"; // Not all are digits
int i2 = atoi(s2) ; // i2 = 123

-obislavu-
 
Thank you, Obislavu!
That's what I was looking for. Knew that function but thought I could only use it with c-style strings (char *).
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top