//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
本文通过一个简单的C++程序介绍了如何实现字符的输入与输出,并展示了如何将字符及其ASCII值显示出来。该程序使用了标准输入输出库,便于初学者理解C++的基本I/O操作。
//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
3220

被折叠的 条评论
为什么被折叠?