c++ 字符串流 <sstream>(常用于格式转换) 未完成

<sstream>使用string对象来代替字符数组。这样可以避免缓冲区溢出的危险。而且,传入参数和目标对象的类型被自动推导出来,即使使用了不正确的格式化符也没有危险。

https://www.cnblogs.com/wyuzl/p/6135537.html 

例子

字符串转成int型

int string2int(string x){
    int a;
    string res=x;
    stringstream ss;
    ss << res;
    ss >> a;
    return a;
}

猜你喜欢

转载自www.cnblogs.com/hemengjita/p/12814460.html