1
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
bool* Str_A = (bool*)calloc(1024,1);
bool* Str_B = (bool*)calloc(1024,1);
*Str_A = true;
*Str_B = true;
*(Str_A+2) = *Str_A+*Str_B;
printf("%s", (Str_A+2)?"true":"false");
}
无论我改变*Str_A
或/和*Str_B
到false
与否,它总是打印true
。 为什么?为什么总是得到相同的布尔值?
谁说'的sizeof(布尔) '肯定是1? – chris
我测试了一分钟前,真的,'sizeof(bool)'是1 – user2967915
你应该检查'*(Str_A + 2)?“true”:“false”',但仍然总是'true'。 –