keil c将数组转为字符串

2025-01-18 11:54:20
推荐回答(1个)
回答1:

设已知数组长度为LENGTH,则新声明一个长度为LENGTH+1的数组:

unsigned char c[LENGTH];
for (i = 0; i < LENGTH; i++) {
if (s[i] < 0x0A) c[i] = s[i] + ' ';
else c[i] = s[i] - 0x0A + 'a';
}
s[i] = 0;