1.1 boost库学习--类型转换(字符串to数值类型)

 

#include <boost/lexical_cast.hpp>
using boost::lexical_cast;

#include <iostream>
using namespace std;

int main()
{
 //string to int
 int a = lexical_cast<int>("123");
 
 //string to double
 double d = lexical_cast<double>("123.123");

 //string to long
 long l = lexical_cast<long>("123456");

 cout<<a<<endl;
 cout<<d<<endl;
 cout<<l<<endl;
 return 0;
}

你可能感兴趣的:(include)