1
char myData[505][3][50];   //2D array, each 50 chars long   
char **tableData[505] = {NULL};  

const char* text;
text = sqlite3_column_text(stmt, col_index);

strcpy(myData[row_index][c_index],text); 

tableData[row_index] = myData[row_index][c_index]; <--?  

I would like to assign the pointer to pointer array tableData to the content of the static array myData but do not know the syntax, or if it possible. Any advice?

4
  • 1
    myData is NOT a static array as you have written it, and your array is 3D (3 dimensions), not 2D as the comment says. Commented Jun 29, 2009 at 19:09
  • @abelenky: His array is a 2D array of 1D arrays. Each 1D array is of size 50. This is exactly like he said :) Commented Jun 29, 2009 at 19:15
  • warning C4047: '=' : 'char ** ' differs in levels of indirection from 'char *' Commented Jun 29, 2009 at 19:15
  • Tommy, oops, yeah. Why tableData[rowIndex] is declared as char** array? I think it should be char* array. What's it going to represent? Commented Jun 29, 2009 at 19:16

2 Answers 2

2

Just

tableData[row_index] = myData[row_index]
Sign up to request clarification or add additional context in comments.

Comments

1

What tableData is going to represent?

If it's going to represent an array of strings (I'll call a char* a string for simplicity in this answer), you should edit the declaration to char* tableData[len];.

If it's going to represent a 2D array of strings (which is what the current declaration means), you should set it as tableData[i] = myData[x].

myData[x][y] is a single string, not an array of strings. In the last line of your snippet, you are trying to assign it to something that expects an array of strings. This is not a valid operation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.