【发布时间】:2012-10-21 01:13:20
【问题描述】:
可能重复:
how do I print an unsigned char as hex in c++ using ostream?
Convert ASCII string into Decimal and Hexadecimal Representations
我想使用 isprint() 打印出字符的十六进制值。但是,我无法让它工作。这是我的尝试:
getline(cin, w);
for(unsigned int c = 0; c < w.size(); c++)
{
if(!isprint(w[c]))
{
cout << "ERROR: expected <value> found " << hex << w[c] << endl;
return 0;
}
}
谁能帮我打印出这个十六进制值?谢谢!我正在输入如下内容:
我
我想要它的十六进制值。
【问题讨论】:
标签: c++