hi everyone))
Please tell me - where is the mistake here -

struct address  {char* city ; char* street; int housenumb ;};
  struct addinf  {int age; struct address*  address;};
  struct student {int number; int kurs; char* name ; struct addinf* addinf;} stud;
  
  
  stud.number=1;
  stud.addinf.address.housenumb =123;

thanks in advance)

addinf and address are both pointers to structures, so you'd need to dereference the pointer before accessing members:

(*(*stud.addinf).address).housenumb = 123;

Alternatively, the arrow operator does this for you in a much more convenient manner:

stud.addinf->address->housenumb = 123;

Note that those pointers must point to something first. Pointers aren't magic.

Edited 5 Years Ago by Narue: n/a

Comments

Note that those pointers must point to something first.

good advice)) but what about this - it isn't right too.... -

if (stud.addinf->address->street == null) putchar(a);

why it's so?

This question has already been answered. Start a new discussion instead.