Mail Archives: djgpp/1997/10/25/17:07:27
Joshua Hab schrieb:
> I have a couple of questions regarding structures and structure pointers...
>
> First, what's the difference between a regular structure and a typedef
> structure? For example, what would be the difference between these two:
>
> struct sprite
> {
> int x, y, color;
> }
/* here's a semicolon missing... */ ;
>
> typedef struct SPRITE
> {
> int x, y, color;
> }
/* here again */ ;
This one does exactly nothing...
you should use: typedef <data type> <new name>, the new name's missing here
typedef gives a data type a new name, for example:
'typedef unsigned int uint;' makes 'uint' equvalent to 'unsigned int'
'typedef struct SPRITE
{
int x, y, color
} NewNameForStructSPRITE;' makes 'NewNameForStructSPRITE' equivalent to 'struct
SPRITE'
>
> Secondly, how exactly does the -> operator work? How is it different from the
> '.' operator? I've know it has something to do with structure pointers, but
> I'm still baffled, I'd really appreciate some direction. :-) Thanks in
> advance.
example:
struct sprite Sprite;
struct sprite *pointer_to_Sprite = &Sprite;
Sprite.x = 1;
pointer_to_Sprite->y = 1;
- Raw text -