传递char [] []作为参数

编程入门 行业动态 更新时间:2024-10-23 11:19:50
本文介绍了传递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 [] []作为参数

本文发布于:2023-10-28 23:26:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538074.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   char

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!