![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Jun 2009
Posts: 2
| How to assign array of pointers to pointers, to content of static array? Code: char myData[90][3][50]; //90 rows, 3 columns, each block 50 chars long
char **tableData[90] = {NULL};
const char* text;
text = sqlite3_column_text(stmt, col_index);
text_lenght = strlen(text) + 1; // add 1 to get null
strncpy(myData[row_index][c_index], text, text_lenght);
//top line in a loop for all rows and each column <--EDIT the assignment is outside the column loop within the row loop.
tableData[row_index] = myData[row_index]; <--?Warning on this line
The warning is: Code: : warning C4047: '=' : 'char ** ' differs in levels of indirection from 'char (*)[50]' Any help is appreciated. Thanks. Last edited by tommy00b; 06-30-2009 at 07:13 PM. |
| tommy00b is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| You need to assign every element of tableData to point where you want it to point. |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jun 2009
Posts: 2
| Assigning each element runtime error I moved the assignment inside the column loop that is within the row loop and I believe this assigns each element, correct? Code: tableData_gmti[row_index][c_index]= myData_gmti[row_index][c_index]; Code: Unhandled exception at 0x0040308e in GUI.exe: 0xC0000005: Access violation writing location 0x00000000. |
| tommy00b is offline | |
| | #4 |
| Guest Join Date: Aug 2001
Posts: 4,923
| >> I need tableData to correctly point to contents of myData but it's not happening. That will never work because 'myData' isn't an array of pointers. Code: int main( int argc, char** argv )
{
const int
ROW_COUNT = 90,
COLUMN_COUNT = 25,
TEXT_LENGTH = 50;
typedef char
text_block[TEXT_LENGTH];
typedef text_block
columns[COLUMN_COUNT];
typedef columns
table[ROW_COUNT] ;
table
myTable;
columns*
myColumns[ROW_COUNT] = {0};
myColumns[8] = &myTable[15];
strncpy(myTable[15][4], "foobar", TEXT_LENGTH - 1);
puts((*myColumns[8])[4]);
}
Last edited by Sebastiani; 06-30-2009 at 07:36 PM. Reason: fixed confusing variable names |
| Sebastiani is offline | |
| | #5 | |
| Registered User Join Date: Oct 2008 Location: TX
Posts: 1,262
| Quote:
Code: char *a[50];
char md[90][3][50];
char **td[90] = {NULL};
a[0] = md[0][0];
td[0] = &a[0];
| |
| itCbitC is offline | |
![]() |
| Tags |
| array, array-of-pointers, multi-dimensional, pointers, static |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array of Pointers to Arrays | Biozero | C Programming | 2 | 04-19-2007 02:31 PM |
| Array of struct pointers - Losing my mind | drucillica | C Programming | 5 | 11-12-2005 11:50 PM |
| Unknown Memory Leak in Init() Function | CodeHacker | Windows Programming | 3 | 07-09-2004 09:54 AM |
| simulate Grep command in Unix using C | laxmi | C Programming | 6 | 05-10-2002 04:10 PM |
| Hi, could someone help me with arrays? | goodn | C Programming | 20 | 10-18-2001 09:48 AM |