1 #include <iostream>
2
3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4 using namespace std;
5 int main(int argc, char** argv) {
6
7 //字符类型变量的声明
8 char c1='A';
9 char c2;
10
11 //字符数据的运算及输出
12 c2=c1+32;
13 cout<<"c1="<<c1<<endl;
14 cout<<"c2="<<c2<<endl;
15
16 //输出字符及ASCII码
17 cout<<c1<<" : "<<int(c1)<<endl;
18 cout<<c2<<" : "<<int(c2)<<endl;
19 cout<<'$'<<" : "<<int('$')<<endl;
20
21 //输入字符
22 cout<<"c1 c2"<<endl;
23 cin>>c1>>c2;
24 cout<<"c1="<<c1<<" c2="<<c2<<endl;
25 return 0;
26 }