安装Boost

一, 安装Boost开发环境

到Boost官网下载boost_1_64_0.zip 这是官网的地址

下载过后安装Boost

在DOS在Boost

可以发现解压后的文件中有一个bootstrap.bat文件。
运行bootstrap.bat

之后会新生成了一个bjam.exe文件
在命令窗口中输入语句:bjam.exe。

这是效果图
boost

二,配置项目的环境

添加boostest工程的包含目录和库目录

包含目录添加 C:\Boost\boost_1_64_0

库目录添加 C:\Boost\boost_1_64_0\stage\lib
Boost_VS

具体如下图
VS_include

VS_lib

三,测试程序


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <boost/lexical_cast.hpp>   
#include <iostream>

using namespace std;


int main(void)
{
    using boost::lexical_cast;

    int a = lexical_cast<int>("123");

    double b = lexical_cast<double>("123.0123456789");

    string s0 = lexical_cast<string>(a);

    string s1 = lexical_cast<string>(b);

    cout << "number: " << a << "  " << b << endl;

    cout << "string: " << s0 << "  " << s1 << endl;

    int c = 0;

    try {

        c = lexical_cast<int>("abcd");

    }

    catch (boost::bad_lexical_cast& e) {

        cout << e.what() << endl;

    }

    printf("\n");
    system("pause");
    return 0;
}

运行效果图
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值