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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -