如何在C++中将一个字符转换成其对应的ASCLL 码

如题所述

第1个回答  推荐于2017-09-29
#include <iostream>
using namespace std;

int main(void){
char c;
while(cin>>c&&c!='q'){
cout<<"The ASCII value of "<<c<<" is "<<static_cast<int>(c)<<endl;
}
return 0;
}本回答被提问者采纳
第2个回答  2009-11-24
强制转换整形就行
第3个回答  2009-11-24
#include<iostream>
using namespace std;
int main(int argv,char **argc)
{
char c;
cin>>c;
cout<<c<<endl;
cout<<(int)c<<endl;
return 0;
}
第4个回答  2009-11-24
用类型强制转
#include<iostream.h>
void main()
{int ch;
char a;
ch=(int)a;
cout<<ch;
}
第5个回答  2009-11-24
printf("%d",字符);

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网