Solved

Casting question

Posted on 2002-03-27
5
281 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
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

809 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