BOOST-lexical_cast

来源:互联网 发布:传奇人形怪数据库 编辑:程序博客网 时间:2024/04/30 00:38

BOOST-lexical_cast

强大的数据转换:

lexical_cast(*argv)

#include <iostream>#include <boost/lexical_cast.hpp>#include <vector>int main(int argc, char * argv[]){    using namespace std;    using boost::lexical_cast;    using boost::bad_lexical_cast;    std::vector<float> args;    while (*++argv)    {        try        {            args.push_back(lexical_cast<float>(*argv));            cout << "Insert into a Data!" << endl;        }        catch(const bad_lexical_cast &)        {             args.push_back(0);        }    }    vector<float>::iterator it;    for(it=args.begin(); it!=args.end(); it++){        cout << "args = " << *it << endl;    }    // ...}//] [/lexical_cast_args_example]
原创粉丝点击