Are static global pointers always initialized to NULL in C? -
this question has answer here:
i learnt global variables initialized '0'. per if declare below line globally,
static char *pointer;
pointer should equal null. true? because in current project, initialized pointer this. when compared pointer == null, becoming false , assigned value. junk address?
all objects static
storage duration (global or not) implicitly initialized 0
or null
if no explicit initializer given.
6.7.9 initialization
...
10 if object has automatic storage duration not initialized explicitly, value indeterminate. if object has static or thread storage duration not initialized explicitly, then:
— if has pointer type, initialized null pointer;
— if has arithmetic type, initialized (positive or unsigned) zero;
— if aggregate, every member initialized (recursively) according these rules, , padding initialized 0 bits;
— if union, first named member initialized (recursively) according these rules, , padding initialized 0 bits;
Comments
Post a Comment