using bool in c (within a structure)
c
Solution
You can't put a `typedef` inside of a struct definition like that. It needs to be at the global level.
typedef enum { false, true } bool;
struct bookshop
{
char name[20];
char issuer[20];
int id;
bool flag;
};
If you have `stdbool.h` available, you can just include that and it will provide the `bool` type as well as the `true` and `false` constants.
Problem
I wanted to use a boolean variable in c as a flag,within a structure,but c does not have any keyword "bool" to make it possible. I got some relevant information here : Using boolean values in C then basically,I tried this ``` struct bookshop { char name[20]; char issuer[20]; int id; typedef enum { false, true } flag; }; ``` to get the following error,on this line:"typedef enum { false, true } flag"; Multiple markers at this line - expected specifier-qualifier-list before ‘typedef’ - Type 'flag' could not be resolved - Syntax error please help! and thanks in advance :)