由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c++ stringstream: how to display hex 0 in 2 digits ?
相关主题
如何判断一个stringstream里面number的类型?new了指针,delete的时候出错了
How to conver CString to long long type?Anybody help me on these questions?
c++ string 一问,[转载] CS Interview question
C++里为什么没有标准化atoi和itoa?[转载] Re: [转载] 这样读多个文件对吗?
C++ string to int conversionstrlen怎么实现的
Array in C请教一个关于字符指针的简单问题
C ++ 问题[转载] Re: 问个土问题吧
[合集] 微软另一道智力题,求救little endian vs big endian
相关话题的讨论汇总
话题: hex话题: digits话题: pbuf话题: 140054
进入Programming版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
the code is like this,
std::stringstream ss;
unsigned char *pBuf;
ss << hex << int(pBuf[i]);
cout << ss.str();
say i have 3 chars, 14, 0, 54.
i got this 14054 instead of 140054,
how to make it print 140054 ?
tried setw(2), didn't work.
t****t
发帖数: 6806
2
setfill('0')
and setw() has to be used before each data.

【在 w*s 的大作中提到】
: the code is like this,
: std::stringstream ss;
: unsigned char *pBuf;
: ss << hex << int(pBuf[i]);
: cout << ss.str();
: say i have 3 chars, 14, 0, 54.
: i got this 14054 instead of 140054,
: how to make it print 140054 ?
: tried setw(2), didn't work.

d**********x
发帖数: 4083
3
The best answer: do not use this freaky thing...

【在 w*s 的大作中提到】
: the code is like this,
: std::stringstream ss;
: unsigned char *pBuf;
: ss << hex << int(pBuf[i]);
: cout << ss.str();
: say i have 3 chars, 14, 0, 54.
: i got this 14054 instead of 140054,
: how to make it print 140054 ?
: tried setw(2), didn't work.

w*s
发帖数: 7227
4
works, thanks a lot !
now i need to worry about BigInt in perl.

【在 t****t 的大作中提到】
: setfill('0')
: and setw() has to be used before each data.

1 (共1页)
进入Programming版参与讨论
相关主题
little endian vs big endianC++ string to int conversion
c++ string 一问Array in C
C++ questionsC ++ 问题
Is it safe?[合集] 微软另一道智力题,求救
如何判断一个stringstream里面number的类型?new了指针,delete的时候出错了
How to conver CString to long long type?Anybody help me on these questions?
c++ string 一问,[转载] CS Interview question
C++里为什么没有标准化atoi和itoa?[转载] Re: [转载] 这样读多个文件对吗?
相关话题的讨论汇总
话题: hex话题: digits话题: pbuf话题: 140054