# 3-dim char array

This is a discussion on 3-dim char array within the C Programming forums, part of the General Programming Boards category; hi, i need to have a table of chars in memory. char array[8][241][26]; each string is 8 chars long. the ...

1. ## 3-dim char array

hi,

i need to have a table of chars in memory.

char array[8][241][26];

each string is 8 chars long. the dimensions of the table is 241 * 26.

i'm confused about how to assign an entry into the array.

for example how do i put 0,0 in?

array[][0][0] = "nnnnnnnn"; or use strcpy

cheers,

rotis23

2. >> each string is 8 chars long. the dimensions of the table is 241 * 26.

Well, which one is for which?

241 - Tables?
26 - Rows?
8 - Chars in each string?

3. Here's a declaration for a 3D char array:

char array[241][26][8];

which means there'll be :

1. 8 chars in a string
2. 26 strings in a table
3. 241 tables

4. thanks, so that won't mean:

char array[241][26][8];

1. 8 chars in a string
2. 26 COLUMNS
3. 241 ROWS

i.e. making a 2-dim table of strings?

i still need to know how to assign a value using strcpy:

strcpy(&array[0][0][0], "nnnnnnnn"); ????

then how do i printf?

printf("array : %s\n",array[0][0][]); ????

5. Just use:
Code:
strcpy(array[0][0], "nnnnn");
And for printing:
Code:
printf("array: %s\n", array[0][0]);
Cheers,
Monster

6. got it using,

char array[241][26][8];

strcpy(&array[0][0][0],"nnnnnnnn");

printf("array : %s\n",array[0][0]);

sorry monster, i'll try yours.