Default of malloc'd bool value within struct in C? -
what value of bool within struct when try access n->mybool? i'm interested know "default" value of bool after allocating memory not assigning true of false value.
#include <stdbool.h> typedef struct node { bool mybool; } node; void main() { node* n = malloc(sizeof(node)); return; }
edit: corrected typo in code (should sizeof(node) not sizeof(node)
there no default value. space allocated malloc
uninitialized, , trying read n->mybool
before writing value cause undefined behaviour.
Comments
Post a Comment