R
Rich Touper
C allows type casting in which a variable is converted from one type
to another.
Does C (whatever standard) allow the type of a variable to change,
within a statement, avoiding the conversion? And if so, provide an
example of how its done.
Example:
int a=23;
int b=34;
char c='a';
int * p_int=(int *) &c;
// type casting
// c is converted into type integer, then b is added.
(int) c + b;
//retypeing
(type int) c + b;
// similar action
*p_int + b
Ignoring alignment issues, storage size issues, etc., c is retyped to
an integer, no conversion is done, and c is used, within the
statement, as an integer, not a char.
Thanks
to another.
Does C (whatever standard) allow the type of a variable to change,
within a statement, avoiding the conversion? And if so, provide an
example of how its done.
Example:
int a=23;
int b=34;
char c='a';
int * p_int=(int *) &c;
// type casting
// c is converted into type integer, then b is added.
(int) c + b;
//retypeing
(type int) c + b;
// similar action
*p_int + b
Ignoring alignment issues, storage size issues, etc., c is retyped to
an integer, no conversion is done, and c is used, within the
statement, as an integer, not a char.
Thanks