Where is the bowl type defined in C?

Asked 2 years ago, Updated 2 years ago, 94 views

How do you use boolean type in C? bool , true, false all red lines appeared Then do I have to solve everything with 1/0 for C?

c boolean

2022-09-22 22:20

1 Answers

In C, there is no bool type, so you have to define and write it yourself. I'll introduce three things that are commonly used

typedef int bool;
#define true 1
#define false 0
typedef int bool;
enum { false, true };
typedef enum { false, true } bool;
#include <stdbool.h>

Choose any of these Personally, I don't like 4 because it can only be used in C99 I think 2 and 3 are better because they don't use #define.


2022-09-22 22:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.