求任意输入字符的ASCⅡ码 (c语言写法)

写出代码

scanf("%c",&t);//输入字符

printf("%d",t);//输出ASCII

例如:

//参考代码如下:
#include<stdio.h>
int main()
{
char a;
scanf("%c",&a);
printf("%d\n",a); 
}
/*运行结果
a
97 
*/
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-05-05
//你那去运行调试马上知道结果
#include <stdio.h>
main()
{
char a;
printf("请输入一个字符:");
scanf("%c",&a);
printf("你输入的字符的ASCII为%d",a);
}
第2个回答  推荐于2017-10-09
char t;
scanf("%c",&t);
printf("%d",(int)t);本回答被提问者采纳
第3个回答  2015-09-12
比如s=“abcdefgh”,则输出:t=“aceg”
程序代码:
#include <stdio.h>
#define SIZE 31
int main(void) {
char s[SIZE] = "abcdefgh", t[SIZE], * p1 = s, * p2 = t;
while(*p1)
*p1 % 2 ? *p2++ = *p1++ : p1++;
*p2 = '\0';
printf("%s\n", t);
return 0;
}
第4个回答  2008-05-05
#include <stdio.h>
#include <stdlib.h>
void main ()
{
int ASCII;
char ch;
printf ("input :");
ch=getchar();

ASCII=(int)ch;
printf ("ASCII=0x%x\n",ASCII);

}