Home:ALL Converter>Dynamic Array Implementation in C

Dynamic Array Implementation in C

Ask Time:2014-02-01T04:20:45         Author:user3224177

Json Formatter

  • Does realloc function in C allocate contiguous memory space?

  • I am trying to implement dynamic integer array. Should I increment pointer by size of array element or by 1?

  • Are there any other better ways to implement dynamic array in C?

Author:user3224177,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/21489326/dynamic-array-implementation-in-c
Mr.C64 :

\nYes, just like malloc() does.\nIf you have an int* ptr which is a pointer to an element of a dynamically allocated int array, a simple ptr++ will point to the next element.\nUsing malloc() and realloc() in C seems to me a good option for dynamic arrays.\n",
2014-01-31T20:25:19
yy