【发布时间】:2019-02-13 11:54:06
【问题描述】:
为什么下面的程序不打印s 字符?:
#include <stdlib.h>
#include <stdio.h>
int main(void) {
unsigned char s = '\0';
unsigned int bits[8] = {0, 1, 1, 1, 0, 0, 1, 1};
for (int i = 0; i < 8; i++) {
s ^= bits[i] << i;
}
printf("%c\n", s);
return 0;
}
所以我基本上是在尝试从位列表中创建s 字符。
为什么我会从这个程序中得到一些其他奇怪的字符?
【问题讨论】:
-
打印什么?尝试以十六进制打印它怎么样,这样你就可以看到发生了什么?
-
@AndrewHenle 它打印这个字符:“Δ
-
î 不是 ascii,因此该值可能没有很好地存储