想通过putchar输出代表真假的0和1,但是输出的结果不符合预期
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a=2,b=3;
int c;
c=(int)(a<b);
putchar(c);
return 0;
}
Process exited after 0.02781 seconds with return value 0
请按任意键继续. . .
a<b为真
将1赋值给c
PS:试过c==(int)(a<b)也不行
再通过putchar输出c的值
输出1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a=2,b=3;
int c;
c=(int)(a<b);
putchar(c+48);
return 0;
}
加上ascll码差值
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a = 2, b = 3;
int c;
c = (int)(a < b);
printf("%d", c);
return 0;
}
这样