•  Back 
  •  C Language 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : C-Language Documentation
Author      : John Kormylo
Version     : C.HYP 1.0
Subject     : Documentation/C-Language
Nodes       : 233
Index Size  : 6362
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : en
@default    : 
@help       : Help
@options    : +g -i -s +x +z -t4
@width      : 75
View Ref-File[ Casting ]

Syntax:
                        ( <type> ) <value>

where <type> is a data type and <value> is an expression, variable or
function name with a different data type.
Returns <value> converted into desired type.

Converting signed char to signed int or signed long will preserve the
sign and value (sign bit extension).  Converting unsigned char to 
unsigned int or unsigned long pads zero's.  Converting signed or
unsigned longs to int or char chops off the left bits (sign bit not
copied).

Check Operator Precedence for correct usage:

  (char*) p + i;       /* convert p to char* and add i bytes */
  (char*) (p + i);     /* add p & i and convert to char*     */
  ((struct s*) p)->pp; /* convert p to struct s* and get pp  */
  (struct s*) p->pp;   /* get p->pp and convert to struct s* */

See also Unary Operators.