[tip]convert string to digit (int, double)

We are used to convert string to int/double by CRT provided functions, 数值和字符串相互转换(C++ 数据类型转换技巧)

 

Actually STL provides more graceful way to do this kind of conversion by istringstream / wistringstream:

        #include<sstream>

        using namespace std;

        double dVal = 0;
        wistringstream wstrStream(str);
        wstrStream >> dVal;
 

 

posted @ 2011-06-01 16:02  能巴  阅读(248)  评论(0编辑  收藏  举报