将十六进制数据0x3EC8A转换成字符型数组{'3','E','C','8','A'}。
怎么把数据变成字符型的数组??{:5_96:} #include <stdio.h>char *ToString(char *buf, int num)
{
sprintf(buf, "%X", num);
return buf;
}
int main(void)
{
char buf;
printf("%s\n", ToString(buf, 0xAA55));
printf("%c\n", buf);
printf("%c\n", buf);
printf("%c\n", buf);
printf("%c\n", buf);
return 0;
}
AA55
A
A
5
5
请按任意键继续. . . char hex[] = "0x3EC8A";
char hex_to_char;
int i;
for(i = 0; i < 5; i++)
hex_to_char = hex;
printf("%s", hex_to_char);
?{:5_96:}
页:
[1]