所以我试图在arraylist中添加一个特定的值。该程序有效,但当我检查是否添加了值时,我每次都得到相同的数字。
void arrayListInsert(struct ArrayList * list, unsigned index, short value){
if(index > list->size){
printf("Index bigger than size ");
return;
}
if(list->size == list->capacity){
short *array=(short *)realloc(list->array,2*sizeof(list->capacity));
list->capacity = list->capacity * 2;
memmove(&array[index],&list->array[list->size-1],sizeof(short *));
array[index]=value;
list->array=array;
list->size++;
}
}