Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(unsigned short (*)[4]) ?

Status
Not open for further replies.

inetd

Technical User
Jan 23, 2002
115
HK
What is the meaning of:

(unsigned short (*)[4])

Thanks.
 
This should be unnamed pointer to an array of 4 unsigned-shorts. Unnamed because this line is probably used for some type-casting.
If you provide few more lines surrounding this one answer could probably be more specific :)
 
Thanks bNasty, I have the following declaration:

unsigned short (*shrink)[3];

shrink = (unsigned short (*)[3])calloc ((width/4) * (height/4), sizeof *shrink);


What is the meaning of this casting?


Thanks.


 
shrink =
(unsigned short (*)[3]) calloc // Result from calloc is treated as 3 pointers to unsigned short's

((width/4) * (height/4), sizeof *shrink); // This is the calculation of the size to allocate


Totte
 
Just to add this : type-casting here was necessary because malloc/calloc return generic (void*) pointer, so you need to "translate" it to what ever you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top