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

来源:百度知道 编辑:UC知道 时间:2024/05/10 08:13:31
写出代码

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

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

例如:

//参考代码如下:
#include<stdio.h>
int main()
{
char a;
scanf("%c",&a);
printf("%d\n",a); 
}
/*运行结果
a
97 
*/

char t;
scanf("%c",&t);
printf("%d",(int)t);

#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);

}

#include <conio.h>
#include <stdio.h>

void main()
{
char c;
while (true)
{
c = getch();
if (c == 27)
break;

printf("%c : %d\n", c, c);
}
}

比如s=“abcdefgh”,则输出:t=“aceg”
程序代码:
#include <