short和unsigned short的控制格式说明分别是什么(十,八,十六进制)?

来源:百度知道 编辑:UC知道 时间:2024/05/30 00:54:29
说反了,应该是格式控制说明

我用程序给你解释一下,我定义了一个char型的变量c='a';从ANSI码表中可以查到a的值为97,我加了两个头文件,iostream用来定义cout输出函数,iomanip则用来定义输出格式,oct为八进制输出,dec是十进制输出,hex是十六进制输出。你可以试一下。。

#include <iostream>
#include "iomanip"
using namespace std;

int main()
{
char c='a';
cout<<oct<<(int)c<<endl;
cout<<dec<<(int)c<<endl;
cout<<hex<<(int)c<<endl;
return 0;

}