我需要通过char获取字符串char的ascii(int和hex格式)表示.例如,如果我有字符串"你好",我会得到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++;
}
Run Code Online (Sandbox Code Playgroud)