0
点赞
收藏
分享

微信扫一扫

Boost 入门之2 - 类型转换

小a草 2022-12-23 阅读 14


相当于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 条评论