guoquanli 发表于 2019-12-2 20:45:14

C语言数组扩容的实现

本帖最后由 guoquanli 于 2019-12-2 21:17 编辑







实现两个链表的拼接:链表内部是用数组实现空间分配的
数组扩容的时候,高亮代码提示:error: assignment to expression with array type,求大神们指点,非常感谢!!

guoquanli 发表于 2019-12-3 10:55:37

for(int i = 0; i <LIST_MAX+ pListQuestB->list_length ; i++){
            temp = pListQuestB->list_data;
      }
将 i <LIST_MAX+ pListQuestB->list_length改为 i<pListQuestB->list_length ,否则pListQuestB->list_data中数组访问会越界,因此报错

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pListQuestA->list_data = temp;
temp是通过malloc动态分配的,pListQuestA->list_data是结构体中封装的长度位100的整型数组,扩容后如何用数组名来访问temp那段内存
(因为其他的函数接口都是对结构体里封装的这个大小固定的数组进行操作的,所以扩容后为了保证其他接口函数的可用性,继续用数组名来访问malloc动态分配的temp对应的那段内存)
*********这个功能如何实现了,望大神们赐教!!
页: [1]
查看完整版本: C语言数组扩容的实现