c++字符字面值常量
c++字符字面值常量 // by 鸟哥 qq1833183060 字符字面量 # include <iostream> # include <string> # include <cstdlib> # include <iomanip> void printCode ( auto c ) { int len = sizeof ( c ) ; std :: cout << std :: hex ; std :: cout << "code:" ; unsigned char * p = ( unsigned char * ) & c ; for ( int i = 0 ; i < len ; i ++ ) { unsigned char code = * ( p + i ) ; if ( code == 0 ) { std :: cout << std :: setfill ( '0' ) << std :: setw ( 2 ) << "0" << " " ; } else { std :: cout << std :: setfill ( '0' ) << std :: setw ( 2 ) << ( int ) code << " " ; } } std :: cout << std :: endl ; } int main ( ) { auto a = 'a' ; /