这是一个小程序打印2到8的功率.但它不会在8后退出.请解释原因.
#include <stdio.h>
#include <unistd.h>
int main(void)
{
unsigned int i=1;
while(1) {
i = i<<1;
printf("i = %d\n",i);
if(i==(2^8))
break;
sleep(1);
}
printf("Exited While loop.. \n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当i = 2 ^ 8时,循环不会退出.我的输出是这样的:
i = 2
i = 4
i = 8
i = 16
i = 32
i = 64
i = 128
i = 256
i = 512 (Should have Exited here. But the program is continuing. Why?)
i = 1024
i = 2048
i = …Run Code Online (Sandbox Code Playgroud) c ×1