Re: How to convert Glib::ustring to float or double



Yes, that should work. You could also just do:

double a = atof(myString.c_str());

They are syntactically the same.

Kevin

On Tue, Aug 14, 2012 at 3:55 PM, Rodrigo Nunes <rnsribeiro gmail com> wrote:
This method work?

Glib::ustring testUString("1.23456789");
char * UStringToCharArray = testUString.c_str();
double floatingPoint = atof(UStringToCharArray);


2012/8/14 Kevin Brightwell <kevin brightwell2 gmail com>
You can also use the usting::c_str() to access the underlying C-style string to pass to atoX methods.




--
Kevin Brightwell
Year 4 Bachelor of Computer Engineering (BESc.)
Year 3 Bachelor of Computer Science (BSc.)

Residence Don - Saugeen-Maitland Hall
Western University www.westernu.ca
e. kevin brightwell2 gmail com c. 226.678.4927



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]