Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Casting question

Posted on 2002-03-27
Medium Priority
311 Views
This question is about casting and

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

/Confused
0
Question by:CrypToniC
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 86

Accepted Solution

jkr earned 200 total points
ID: 6899279
>>Does
>> 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***'
0

LVL 5

Expert Comment

ID: 6899859
CryptToniC,
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

0

LVL 5

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)
0

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.
0

LVL 1

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
0

## Featured Post

Question has a verified solution.

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

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 SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. 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.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
###### Suggested Courses
Course of the Month11 days, 13 hours left to enroll