Variable Sized Arrays vs calloc in C

前端 未结 5 1970
挽巷
挽巷 2020-12-03 06:37

On the discussion of dynamic memory here: \"Intro to C Pointers and Dynamic Memory\"

The author states:

A memory block like this can effective

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 07:05

    I agree with ocdecio that c89 doesn't allow

    int array[variable]
    

    c99 allows some types of variables and expressions to be the array size. But in addition to that, things allocated with malloc and family can be resized using realloc.

提交回复
热议问题