[cfe-dev] Question about array accesses

Csaba Raduly rcsaba at gmail.com
Fri Feb 14 00:47:14 PST 2014


Hi Prateek,

On Thu, Feb 13, 2014 at 7:26 AM, Prateek Saxena
<thisisprateeksaxena at gmail.com> wrote:
> Hi.
>
> Given a multi-dimensional array like
> int a[3][5][6];
>
> what would be a good way of calculating the offset of an element like
> a[1][1][1] from the base pointer to a ?

This is a mailing list for discussing clang the C/C++/ObjC compiler.
Your question belongs to a forum for general C++ questions, for
example Stackoverflow.

Have you tried

&(a[1][1][1]) - &(a[0][0][0])

?

Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds



More information about the cfe-dev mailing list