In main:
char *myData[500][9]; //dynamic rows??
char **tableData[500]={NULL}; //dynamic rows??
int r;
newCallBack(db, &myData, &tableData, &r);
and passing into function by:
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....
Thanks.
If you were to rewrite this as such:
#define NUM_ROWS 500;
#define NUM_COLS 9;
char **myData = NULL;
char *tableData = NULL;
int i;
int r;
myData = malloc(sizeof(char *) * NUM_ROWS);
if (!myData)
return; /*bad return from malloc*/
tableData = malloc(sizeof(char) * NUM_ROWS);
if (!tableData)
return; /*bad return from malloc*/
for (i = 0; i < NUM_ROWS; i++)
{
myData[i] = malloc(sizeof(char) * NUM_COLS);
if (!myData[i])
return; /*bad return from malloc*/
}
You would then call newCallBack() like this if you just wanted access to the data (myData, tableData, and r):
/*prototype*/
void newCallBack(sqlite3 *db, char** mdat, char* tdat, int r);
/*call*/
newCallBack(db, myData, tableData, r);
Or this if you want to be able to modify what the vars myData and tableData point to and the value of r:
/*prototype*/
void newCallBack(sqlite3 *db, char ***mdat, char **tdat, int *r);
/*call*/
newCallBack(db, &myData, &tableData, &r);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With