First ! 字符转换ASCII 码
#include<bits/stdc++.h>
using namespace std;
int main( )
{
char a, b;
cin >> a;
cin.get();
cin >> b;
cout << "The ASCII code of " << a << " is " << int(a) <<endl;
cout << "The ASCII code of " << b << " is " << int(b) <<endl;
return 0;
}
Second !ASCII 转换为字符文章来源:https://www.toymoban.com/news/detail-745454.html
#include<bits/stdc++.h>
using namespace std;
int main( )
{
int a, b;
cin >> a;
cin.get();
cin >> b;
cout << "The ASCII code of " << a << " is " << char(a) <<endl;
cout << "The ASCII code of " << b << " is " << char(b) <<endl;
return 0;
}
Last! 在一个代码块里面,实现两种形式的互相转换 这里只给出思路:首先就是要判断我们输入的类型,然后根据类型来调用对以上两个封装的函数。文章来源地址https://www.toymoban.com/news/detail-745454.html
到了这里,关于c++中实现ASCII码和字符的相互转换的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!