C has a header file stbool.hfor using variables bool.
So it works
#include <stdio.h>
#include<stdbool.h>
int main(void) {
int i=1;
while(true)
{
if(i==3){
break;
}
printf("%d\n",i);
i++;
}
return 0;
}
Output
1
2
note: Modern C99 supports variables bool, but C89 / 90 does not.
If you use C89 / 90, you can use typedefeither constants, as indicated in one of the answers here, or you can use the enumssame as this
typedef enum {false, true } bool;
bool b=true;
int i=1;
while(b)
{
if(i==3){
break;
}
printf("%d\n",i);
i++;
}
Output
1
2
You can check this bool in C
Hope this helps you.
source
share