• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

C++生成标准的ASCII编码表

OC/C/C++ 水墨上仙 1499次浏览

C++生成标准的ASCII编码表

/*
The standard ASCII table defines 128 character codes (from 0 to 127), of
which, the first 32 are control codes (non-printable), and the remaining 96
character codes are representable characters:
*/
 
#include <iostream>
#include <iomanip>
using namespace std;
 
int main()
{   int i,j;
    char cmd[32][4]= {"NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","TAB",
                      "LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK",
                      "SYN","ETB","CAN","EM","SUB","ESC","FS","GS","RS","US"};
     cout << "The standard ASCII table defines 128 character codes (from 0 to 127),";
     cout << "\n of which,the first 32 are control codes (non-printable), and the";
     cout << "\n remaining 96 charactercodes are representable characters:\n";
        cout << "*";
    for( i = 0 ; i < 10 ; i++)
        cout << setw(4) << i;
 
    for( i = 0x41 ; i < 0x47 ; i++)
        cout << setw(4) << static_cast<char>(i);
        cout << endl << "-- ";
 
    for( i = 0 ; i < 16 ; i++)
     cout << left << "--- ";
 
    for( i = 0 ; i < 2 ; i++ )
        {
            cout << endl <<  i << "| " ;
 
    for(j = 0 ; j < 16 ; j++)
        cout << setw(4) << left << cmd[i*16+j];
        }
    for( i = 2 ; i < 8 ; i++ )
        {
        cout << endl << i << "| " ;
    for( j = 0 ; j < 16 ; j++)
            if((i*16 + j) != 127 )
         cout << setw(4) << left << static_cast<char>(i*16+j);
        }
    cout << endl << endl;
    return 0;
}
/*Program's output
The standard ASCII table defines 128 character codes (from 0 to 127),
 of which,the first 32 are control codes (non-printable), and the
 remaining 96 charactercodes are representable characters:
*   0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
-- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
0| NUL SOH STX ETX EOT ENQ ACK BEL BS  TAB LF  VT  FF  CR  SO  SI
1| DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM  SUB ESC FS  GS  RS  US
2|     !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
3| 0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
4| @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
5| P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
6| `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
7| p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~
 
 
Process returned 0 (0x0)   execution time : 0.078 s
Press any key to continue.
 
*/


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明C++生成标准的ASCII编码表
喜欢 (0)
加载中……