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
5
Medium Priority
?
311 Views
Last Modified: 2010-04-15
This question is about casting and
leading *:s

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

/Confused
0
Comment
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
  • Learn & ask questions
5 Comments
 
LVL 86

Accepted Solution

by:
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

by:BlackDiamond
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

by:BlackDiamond
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

by:0xDEADBEEF
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

by:CrypToniC
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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.

636 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