Ç - 通过与已知大小的参考多维数组传递 [英] C - Pass by reference multidimensional array with known size

查看:124
本文介绍了Ç - 通过与已知大小的参考多维数组传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在主要的:

char *myData[500][9]; //dynamic rows??
char **tableData[500]={NULL};         //dynamic rows??
int r;

newCallBack(db, &myData, &tableData, &r);

和突入功能是:

void newCallBack(sqlite3 *db, char** mdat, char*** tdat, int* r )
{

似乎不也是这样吗?有什么建议么?例子很多在线的时候你不知道的大小,现在想出来....

Doesn't seem to like this? Any suggestions? Lots of examples online when you don't know the size, trying them out right now....

感谢。

推荐答案

首先,与MYDATA的问题是,这是错误的类型。字符* [] []将要求你调用该函数的原型字符***(字符串的二维数组)。该函数想要一个字符串列表,这为char * [],或者烧焦[] [],如果你不介意的限制字符串的大小。

First of all, the problem with myData is that it's the wrong type. char* [][] would require a prototype char*** (a two-dimensional array of strings) in the function you're calling. The function wants a list of strings, which is char* [], or alternatively char[][], if you don't mind limiting the size of the strings.

要获得完全动态数组的大小,你必须手动分配(和释放!)使用malloc()和free()的内存,并更改类型的变量为char **的myData和char ***资料表。

To get fully dynamic array sizes you'll have to manually allocate (and release!) memory with malloc() and free(), and change the types of your variables to char **myData and char ***tableData.

这篇关于Ç - 通过与已知大小的参考多维数组传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆