#include<stdio.h>
void ascii()
{
//code goes here
}
int main()
{
int b;
char a;
b=ascii(a);
printf("%d",b);//Expecting the ASCII Value of a to printed.
return 0;
}
期望 printf 语句给出 a 的 ASCII 值。
提前致谢。
最佳答案
不需要像 ascii()
这样的函数。出于这个目的,这有点矫枉过正,如果我可以这样说的话。
简单使用
char x = 'a';
printf("Symbol table index of %c is %d\n", x, x);
请注意,这仅在您的平台使用 ASCII 时有效 - 例如,对于具有 EBCDIC 字符集的 IBM 系统,这不会返回字符的 ASCII 值,您需要使用查找表。
关于c - 如何使用 C 中的函数查找给定字符的 ASCII 码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30485431/