摘要:
方法一:形参给出第二维的长度。例如:#include<stdio.h>#include<math.h>#include<ctype.h>#include<string.h>#include<stdlib.h>voidfunc(intn,charstr[][5]){inti;for(i=0;i<n;i++)printf("\nstr[%d]=%s\n",i,str[i]);}intmain(){char*p[3];charstr[][5]={"abc","def",&qu 阅读全文
posted @ 2011-04-20 00:32
cpoint
阅读(1358)
评论(0)
推荐(0)
摘要:
原理: 在C语言中数组下标访问可以看成指针的偏移访问1、对表进行检查,看看它是否真的已满2、如果表确实已满,使用realloc()函数扩展表的长度,并进行检查,确保realloc()操作成功进行。3、在表中增加所需要的项目code:intcurrent_element=0;inttotal_element=128;char*dynamic=malloc(total_element);char*ptr;voidadd_element(charc){if(current_element==total_element-1){total_element*=2;ptr=(char*)realloc(dy 阅读全文
posted @ 2011-04-20 00:17
cpoint
阅读(2314)
评论(0)
推荐(0)

浙公网安备 33010602011771号