PDA

Click to See Complete Forum and Search --> : Convert a string (not char *) to a number


V(ery) Basic
Oct 7th, 2000, 08:12 AM
I've got a number from a textbox which is in the form of a string (from string.h, not a char * thing) and it has quite a few methods and stuff, and I was wondering which one converts the string to a, for example, float or long int ?

I couldn't find anything on MSDN, and none of the methods say 'toNumber' or anything. Please, it is quite important since what use is a calculator project which doesn't bloody well know what numbers we're dealing with?

Thanks,

le MOI

parksie
Oct 7th, 2000, 11:07 AM
You mean the STL string class?

In that case, try atof/atoi with the c_str() member function of your string object.

V(ery) Basic
Oct 7th, 2000, 12:25 PM
Originally posted by parksie
You mean the STL string class?


Errr. Probably?

Thanks for the advice. I know about ato-x- and but I didn't know that c_str changed the string into something useful.

Thanks again, Mikey boy,

DJ Da Arse