Casting question

Posted on 2002-03-27
Last Modified: 2010-04-15
This question is about casting and
leading *:s

  a_p = ***(void****)b_p
make sence ?
Is it the same as
  a_p = *(void****)b_p ???

Question by:CrypToniC
LVL 86

Accepted Solution

jkr earned 50 total points
ID: 6899279
>> a_p = ***(void****)b_p
>>make sence ?

Yes, absolutely. I mean, if 'b_p' is of type 'void****', of course,

>Is it the same as
> a_p = *(void****)b_p ???

No, not at all - this makes 'a_p' an 'void***'

Expert Comment

ID: 6899859
jkr is absolutely correct.   I will elaborate a couple more examples that should hopefully make the derefrencing more clear.

void a_p = ****(void****)b_p
void * a_p = ***(void****)b_p
void ** a_p = **(void****)b_p
void *** a_p = *(void****)b_p
void **** a_p = (void****)b_p


Expert Comment

ID: 6899881
also, I only included the first line for clarity.  It is actually illegal to have a (void) variable (since it would have no context of size).  The way you would use the first line would be more like:

int a_p = (int)(****(void****)b_p)

Expert Comment

ID: 6902088
Hmmm... a void**** variable would indicate a 3d-array of pointers to void, so

void* a_p = ***(void****)b_p

would be the same as

void* a_p = b_p[0][0][0];

so a_p is a pointer to void, or, the contents of a slot.  But

void*** a_p = *(void***)b_p;

would equal

void*** a_p = b_p[0];

so a_p would be a pointer to a pointer to a pointer to void, or, a 2d-array of pointers to void.

Hope this helps, I know it's confusing.

Author Comment

ID: 6912223
jkr, was the first to answer so this seems fair

Hmm if one returns to basics the answer is often obvious :)

Not often I see code like this, Thanks alot
Regards CrypToniC

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Estimate porting issues. 9 120
C++ vs C compilers 13 160
C Programming - If Statement 8 82
A  &&  B  || (C||D) how it works in c 7 100
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question