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

How The Address or Value Access from 3D array using pointers?

P: 96
Expand|Select|Wrap|Line Numbers
  1. main( )
  2. {
  3.   int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
  4. printf("%u %u %u %d \n",a,*a,**a,***a);
  5. printf("%u %u %u %d \n",a+1,*a+1,**a+1,***a+1);
  6.       }

If the location of an array start from 100.

can you please explain all this by giving the demonstration of how the location is saved from one to other & how the location & the value is access please explain in detail.
Thank you
Jun 1 '10 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 8,972
You might want to start by running the code and seeing if you can explain it.

As a tip it may (or may not) help if all the values in the array have different values so you can easily differentiate them.
Jun 1 '10 #2

Expert Mod 5K+
P: 9,197
You might also read this article:

There is a lot of info here about how arrays actually work.
Jun 1 '10 #3

Expert 100+
P: 2,418
You are using %u (unsigned int) to print [some] pointer values. Are you sure int is wide enough on your platform?

I suggest changing your array declaration from int to unsigned long and then using conversion specifier "%lu". Unsigned long isn't guaranteed to be wide enough to hold a pointer value either, but from a practical point of view it is good enough.
Jun 1 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.