gpt4 book ai didi

c - 在 C 中打印 ASCII 代码值及其等效字符

转载 作者:太空宇宙 更新时间:2023-11-04 08:28:34 24 4
gpt4 key购买 nike

如何为给定的 ASCII 代码值打印字符?..

我看到了这个question ,我的问题类似,恰恰相反

下面是我的程序,但它不起作用。

int main (){
int code; // code that user enters
char ch; //"codes" related ASCII charcter

printf("Enter a ASCII code value: \n");
scanf("%d", &code);
ch=code;

printf(" %c is cherechter that have %d ASCII code\n", &ch ,&code);

system("PAUSE");
return 0;}

最佳答案

在您的代码中,您必须更改 printf 语句

printf(" %c is cherechter that have %d ASCII code\n", &ch ,&code);

printf(" %c is cherechter that have %d ASCII code\n", ch ,code);

因为,要打印,您不需要提供变量的地址。变量名就够了。

关于c - 在 C 中打印 ASCII 代码值及其等效字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29366853/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com