+ 1
why C does not have a boolean type ?
why C does not have a boolean type ?
4 Respuestas
+ 7
It has :
_Bool b = 1;
It stores either 1 or 0 as boolean value
edit:
#include <stdio.h>
int main() {
_Bool b = 1;
if(b)
printf("boolean");
return 0;
}
+ 5
Just for fun prior to stdbool.h
#include <stdio.h>
//define boolean values
#define TRUE 1
#define FALSE 0
int main(void){
int i = 3;
int flag = FALSE; //set boolean flag
if(i == 3){
flag = TRUE;
}
printf("%i\n", flag);
}
output: 1
+ 3
Thank you