What are some useful examples of malloc() in C?

前端 未结 6 1456
傲寒
傲寒 2020-12-15 08:16

I\'m just reading about malloc() in C.

The Wikipedia article provides an example, however it justs allocate enough memory for an array of 10 ints in com

6条回答
  •  既然无缘
    2020-12-15 08:54

    In the example you described int array[10] goes away when you leave your stack frame. If you would like the used memory to persist beyond local scope you have to use malloc();

提交回复
热议问题