本文介绍了传递char [] []作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试传递此数组
I''m trying to pass this array
展开 | 选择 | Wrap | 行号 推荐答案& ;(files [0] [0])类型为char * 但 int fillFileArr(char ** files,char * buf ,int num) 是一个期待char **的函数。实际上我很惊讶这实际上并没有产生任何编译器警告。 另外文件[word] [wordPos ++] = buf [bufferPos];试图假装函数内的文件仍然是char [] [],但它不是。 maxLen是否已修复? (即常数)如果是这样你可以尝试 int fillFileArr(char(* files)[maxLen + 8],char * buf,int num) > 否则你可能需要传入一个char *并指向数组的2个维度。 &(files[0][0]) has type char * but int fillFileArr(char ** files, char * buf, int num) is a function expecting char **. Actually I am rather surprised that this doesn''t actually produce any compiler warnings. Also files[word][wordPos++] = buf[bufferPos]; is trying to pretend that files inside the function is still a char [][] but it isn''t. Is maxLen fixed? (i.e. a constant) if so you could try int fillFileArr(char (*files)[maxLen+8], char * buf, int num) otherwise you probably need to pass in a char * and the 2 dimensions of the array pointed to.
if(fillFileArr(&(files [0] [0] ),&(buf [0]),num)== - 1)错误:是&(files [0] [0])类型为char **?我建议你阅读这个。 编辑:哎呀,班法更快。 if(fillFileArr(&(files[0][0]), &(buf[0]), num)==-1) is wrong: is &(files[0][0]) of type char ** ? I suggest you read this. Oops, Banfa was faster.
它可能在这里: It probably here: 展开 | 选择 | Wrap | 行号
更多推荐
传递char [] []作为参数
发布评论