suncode

  博客园 :: 首页 :: 新随笔 :: :: :: 管理 ::

2011年3月28日

摘要: 要实现这个目标,非stringstream类莫属。这个类在<sstream>头文件中定义,<sstream>库定义了三种类:istringstream、ostringstream和stringstream,分别用来进行流的输入、输出和输入输出操作。另外,每个类都有一个对应的宽字符集版本。string到int类型的转换<sstream>使用string对象来代替字符数组。这样可以避免缓冲区溢出的危险。而且,传入参数和目标对象的类型被自动推导出来,即使使用了不正确的格式化符也没有危险。std::stringstream stream;string result= 阅读全文
posted @ 2011-03-28 10:01 suncode 阅读(4494) 评论(0) 推荐(0)