Difference between malloc and realloc?

前端 未结 3 1842
死守一世寂寞
死守一世寂寞 2021-02-13 03:18

Suppose I\'ve two code samples for creating a integer array of 10 elements:

int *pi = (int*)0; 
realloc(pi,10);

and the other is the one that i

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 04:16

    C requires that the pointer passed to realloc must be a pointer obtained from malloc, calloc or realloc function call (or a null pointer).

提交回复
热议问题