字符转 ASCII 码

#include <stdio.h>
int main()
{
    char c;
    printf("输入一个字符: ");

    // 读取用户输入
    scanf("%c", &c);

    // %d 显示整数
    // %c 显示对应字符
    printf("%c 的 ASCII 为 %d", c, c);
    return 0;
}
D:\C++Test\cmake-build-debug\otherTest.exe
输入一个字符:v
 v 的 ASCII 为 118
Process finished with exit code 0

猜你喜欢

转载自blog.csdn.net/alspd_zhangpan/article/details/107693584