What is the most appropriate way to simulate type bool
in C? My teacher did it quite simply.
#define bool int
But I also found an excellent answer aqui ( follows a copy of the code).
// Criando a enumeração:
enum boolean {
true = 1, false = 0
};
// Permitindo a sua declaração como um tipo qualquer:
typedef enum boolean bool;
// Agora podemos escrever e compilar os códigos como:
int main () {
bool b = true;
if (b) {
b = false;
}
return 0;
}
What are the pros and cons of both types of claims and where can they cause me a headache in the future if I implement them in a library?