The Way To Great
通往伟大的路
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
z w
ID:zinking3
共
49353
次访问,排名
2041
好友
13
人,关注者
18
人
where there is a will,there is a way to great.
zinking3的文章
原创 190 篇
翻译 6 篇
转载 14 篇
评论 22 篇
Albert的公告
最近评论
强悍的沉默:
辛苦了
songhuanren:
不错.,很有价值,但as3的项目好像就不行了吧.
assicen:
自我认为 在目前看来C/C++并非程序员必须掌握的语言 领域不同 应用不同 当然语言也不会相同
寒雨:
说的不错,要想在更深入的发展,必须把基础学好,c/c++是最基础的,哥们有同感!!!知己呀··
Johnshen007:
看上去相当不错,支持!
文章分类
.NET
(RSS)
JAVA
(RSS)
LINUX
(RSS)
MATH
(RSS)
RIA
(RSS)
SHELL SCRIPT
(RSS)
人工免疫
(RSS)
生活感悟
(RSS)
收藏
FLASH LITE
相册
RIA的朋友们
不会飞的鱼
更新很快,关注业内的RIA朋友Y-Boy
(RSS)
存档
2008年05月(1)
2008年04月(25)
2008年03月(31)
2008年02月(10)
2008年01月(18)
2007年12月(62)
2007年11月(13)
2007年10月(21)
2007年09月(9)
2007年08月(4)
2007年07月(8)
2007年06月(8)
订阅我的博客
【C&C++】stringstream的一些用法 - 尝试一下新的东西
收藏
新一篇: 【多目标优化】Pareto最优解很少
|
旧一篇: 【C&C++】上海交大以前的一道复试题
#include
<
iostream
>
#include
<
fstream
>
#include
<
cstdlib
>
#include
<
cstring
>
#include
<
sstream
>
#include
<
bitset
>
using
namespace
std;
int
main()
...
{
/**/
/*
string stream tests
*/
/**/
/*
string stream for type conversions
*/
//
stringstream ss;
//
string n="123.456";
//
float f=0.0f;
//
ss << n; ss >> f; cout << f <<endl;
//
string stream for type conversions
//
f+=333.1458f;
//
ss.clear();
//
多次转换之前必须将流清空
//
ss << f; ss >> n; cout << n << endl;
//
ss.clear();
//
int a=12;stringstream ss;
//
string n;
//
ss.flags ( ios::hex | ios::showbase );
//
ss << a;
//
输出0X12
//
ss >> n;
//
这样都可以 直接得到16进制的字符串了
//
stringstream ss;bitset<16> a(12);string n;
//
ss << a; ss >> n;
//
cout << n ; 这样就可以转为2进制的字符串了,太强了
/**/
/*
stringstream ss;
ss << "123,456";
string s1;
getline(ss,s1,',');//分割字符串,PARSE
cout << ss.peek();
*/
return
0
;
}
发表于 @
2008年03月23日 14:05:00
|
评论(
loading...
)
|
编辑
新一篇: 【多目标优化】Pareto最优解很少
|
旧一篇: 【C&C++】上海交大以前的一道复试题
评论
#
sheds 发表于2008-03-24 07:54:17 IP: 116.25.203.*
怎么不把结果贴出来呢
发表评论
姓 名:
主 页:
校验码:
看不清,换一张
登录