Posts

Showing posts with the label pointers

Boolean types using function pointers

There are many ways to use Boolean  date types in C. C99 standard library <stdbool.h> or many others, one just need to "google". While reading book "Understanding and Using C Pointers" it came to my mind that another way to define Boolean type is C pointers. Something like this: typedef void (*bool)(); void true() {} void false(){} To use it we can simply do that: bool is_correct; is_correct = false; Here is a working example: