Boost 入门之2 - 类型转换

小a草

关注

阅读 16

2022-12-23


相当于atio,aof.

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

#include <boost\lexical_cast.hpp>
using namespace boost;

int _tmain(int argc, _TCHAR* argv[])
{
int i = 888;
string str = "999";
i = boost::lexical_cast<int>(str);
cout << i << endl;//输出整数:999

str = "123.123";
float f = boost::lexical_cast<float>(str);
cout << f << endl;//输出浮点数: 123.123

getchar();
return 0;
}


精彩评论(0)

0 0 举报