[vtkusers] vtkstd::string from string to numers
David Doria
daviddoria+vtk at gmail.com
Sat Feb 20 08:47:11 EST 2010
On Sat, Feb 20, 2010 at 8:42 AM, Giancarlo Amati <ilferraresebono at hotmail.it
> wrote:
> Hello Users,
>
> is thre any functions in the std::string which converts strings into
> correspondent numbers?
>
> I mean "123.40" = double 123.40
>
> Many thanks.
> GC.
>
You should use string streams:
#include <sstream>
std::string strNumber = "23.4";
std::cout << "strNumber = " << strNumber << std::endl;
std::stringstream ss;
ss << strNumber;
double dNumber;
ss >> dNumber;
std::cout << "dNumber = " << dNumber << std::endl;
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100220/82b8135f/attachment.htm>
More information about the vtkusers
mailing list