我需要通过 char 获取字符串 char 的 ascii(整数和十六进制格式)表示。例如,如果我有字符串“hello”,我会得到 int ascii 104 101 108 108 111
对于 hex 68 65 6C 6C 6F
最佳答案
怎么样:
char *str = "hello";
while (*str) {
printf("%c %u %x\n", *str, *str, *str);
str++;
}
关于c - 如何获取字符串的 ASCII,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11590914/