1. 程式人生 > >輸入一個字元常量,輸出此字元常量對應的整數值。

輸入一個字元常量,輸出此字元常量對應的整數值。

//File Name:Test.cpp

#include <iostream>

using namespace std;

int main()

{

char c;

cout<<”Input a char :”<< endl;

cin>> c;

cout<<”The value of  ”<< c <<int (c)<<endl;

}

編譯:g++ –o  test Test.cpp

執行:./test