c - Bool: Direct assignment or conditional? -
what's "proper" c way of assigning bool?
#include <stdbool.h>   a)
bool a_state = (a_value > 0);   b)
bool a_state; if (a_value > 0) {a_state = true;} else {a_state = false;}   c)
bool a_state = false; if (a_value > 0) {a_state = true;}   d)
bool a_state = (a_value > 0)? true: false;   which 1 clearer , more "c-like"?
edit: added 2 more; added bool header #include
its matter of choice. can go either. first snippet equivalent second.
Comments
Post a Comment