pointer default value .?

前端 未结 4 1195
生来不讨喜
生来不讨喜 2020-12-03 05:52

Look,

  typedef struct jig 
   { 
         int *a;
         int *b;
   }temp;

now stage 1 :

temp *b;
b= (         


        
4条回答
  •  孤街浪徒
    2020-12-03 06:15

    Chance, that's what's happening. Nobody says uninitialized, non-static memory needs to hold any value. Both could contain anything.

    • In the first case it simply happened that malloc returned memory from an erased page (so it contains 0)
    • In the second case there was stuff on the stack so the memory contains garbage

提交回复
热议问题