Menu Close

C语言练习:输入一个字符,输出其ASCII码

ASCII ((American Standard Code for Information Interchange): 美国信息交换标准代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言。 它是最通用的信息交换标准,并等同于国际标准ISO/IEC 646。

给如一个字符,可以用0-127之间的数表示。

#include <stdio.h>
int main()
{
    char ch;
    printf("Enter any character:");

    /* Reads the entered character and stores it
     * into the char variable ch
     */
    scanf("%c", &ch);

    /* Using the format specifiers we can get the ASCII code
     * of a character. When we use %d format specifier for a
     * char variable then it displays the ASCII value of a char
     */
    printf("ASCII value of character %c is: %d", ch, ch);
    return 0;
}
Enter any character:q
ASCII value of character q is: 113
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Leave the field below empty!

Posted in C语言习题集

Related Posts