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

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -