c - Pointer to a struct -
I'm trying to understand more points and I'm having trouble with this example.
Typedef struct {int areaCode; Int street number; } Address; Address * Extra; Addr-> Field code = 10000; Printf ("% d \ n", addr-> field codes);
I get a segmentation fault and it does not understand why
addr is an indicator for a address structure, so I also tried it :
* addr-> Area code = 10000;
Even more "indirection requires pointer operator", any thoughts?
address * addr;
You have declared only one indicator addr
, but it points to something unknown here. You have not allocated memory space for it.
To fix this, change
address * addr = malloc (sizeof (address));
Comments
Post a Comment