打印字符和用C的ASCII- code [英] Printing chars and their ASCII-code in C

查看:111
本文介绍了打印字符和用C的ASCII- code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何打印字符,并用C它的等效ASCII值?

How do I print a char and its equivalent ASCII value in C?

推荐答案

本打印出所有ASCII值

This prints out all ASCII values

int main()
{
    int i;
    i=0;
    do
    {
        printf("%d %c \n",i,i);
        i++;
    }
    while(i<=255);
    return 0;
}

和本打印出的ASCII值给定字符:

and this prints out the ASCII value for a given character:

int main()
{
    int e;
    char ch;
    clrscr();
    printf("\n Enter a character : ");
    scanf("%c",ch);
    e=ch;
    printf("\n The ASCII value of the character is : %d",e);
    getch();
    return 0;
}

这篇关于打印字符和用C的ASCII- code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆