C variable retyping
From: Groups User (googlegroups_001_at_yahoo.com)
Date: 08/27/04
- Next message: CBFalconer: "Re: Two Questions about "strlen", "strcat" and "strcpy""
- Previous message: Skybuck Flying: "Re: another stupid c bug. (endless for loop)"
- Next in thread: Eric Sosman: "Re: C variable retyping"
- Reply: Eric Sosman: "Re: C variable retyping"
- Reply: Mark A. Odell: "Re: C variable retyping"
- Reply: Martin Ambuhl: "Re: C variable retyping"
- Reply: Chris Torek: "Re: C variable retyping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Aug 2004 10:19:57 -0700
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
- Next message: CBFalconer: "Re: Two Questions about "strlen", "strcat" and "strcpy""
- Previous message: Skybuck Flying: "Re: another stupid c bug. (endless for loop)"
- Next in thread: Eric Sosman: "Re: C variable retyping"
- Reply: Eric Sosman: "Re: C variable retyping"
- Reply: Mark A. Odell: "Re: C variable retyping"
- Reply: Martin Ambuhl: "Re: C variable retyping"
- Reply: Chris Torek: "Re: C variable retyping"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|