数值换换为字符串(3)

来源:互联网 发布:js 订阅发布模式代码 编辑:程序博客网 时间:2024/05/16 14:21

采用Boost库中的lexical_cat实现数值到字符串的转换

Boost库下载地址:www.boost.org


#pragma warning(disable:4996)#include <iostream>#include <cstdlib>#include <string>using namespace std; #include <boost/lexical_cast.hpp>using namespace boost; int main(int argc, char **argv){ //定义需要需要转换的数值int i =10;//定义字符串变量std::string str;//采用boost库中的lexical_cast函数可以实现任意类型数值到字符串的转换str = boost::lexical_cast<std::string>(i);std::cout<<str<<std::endl;return EXIT_SUCCESS;}

0 0
原创粉丝点击