Why does malloc initialize the values to 0 in gcc?

前端 未结 9 1913
慢半拍i
慢半拍i 2020-11-22 16:34

Maybe it is different from platform to platform, but

when I compile using gcc and run the code below, I get 0 every time in my ubuntu 11.10.

#include         


        
9条回答
  •  逝去的感伤
    2020-11-22 16:48

    Do you know that it is definitely being initialised? Is it possible that the area returned by malloc() just frequently has 0 at the beginning?

提交回复
热议问题