By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,301 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,301 IT Pros & Developers. It's quick & easy.

pointer to 3dimension array

P: n/a
hi
how to declare pointer to 3dimention array?
for example: I've 2 3D arrays
char s1[24][5][5];
char s2[24][5][5];
and i'd like to have A POINTER, which could point one time to array s1 and
second time to array s2:
char *s[][][]; // BAD DECLARATION !!!
....
// one time
s = s1;
s[10][2][4] = 'a';
....
// second time
s = s2
s[19][3][1] = 'b';
.....
// third time
s = s1;
....
....
....
// n'th time
s = s2

but I do not know how to declare this pointer.
please, help me.
Thanks in advance
Adam
Jun 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Adam wrote:
hi
how to declare pointer to 3dimention array?
for example: I've 2 3D arrays
char s1[24][5][5];
char s2[24][5][5];
and i'd like to have A POINTER, which could point one time to array s1 and
second time to array s2:
char *s[][][]; // BAD DECLARATION !!!
char (*s)[24][5][5];
// one time
s = s1;
s[10][2][4] = 'a';
Hmm, then instead of a pointer to the array itself, a pointer to the first
element would be better:

char (*s)[5][5];

...
// second time
s = s2
s[19][3][1] = 'b';
....
// third time
s = s1;
...
...
...
// n'th time
s = s2

but I do not know how to declare this pointer.
please, help me.
Thanks in advance
Adam


Jun 28 '06 #2

P: n/a
It works !!! :)
thx very much
best regards
Adam
Jun 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.