c - What happens when you calloc a struct containing an enum type? -


typedef enum { false, true }bool;  struct { bool value_set; int value; } 

what happens when struct allocated using calloc? enum hold false default value? since calloc sets memory 0.

an enum integral type. if don't assign them values, start @ 0 , increase. therefore typedef equivalent

typedef enum { false = 0; true = 1; } bool; 

therefore calloc set value_set 0 equal false.


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -