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.

commented: ++++ +1

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?

null isn't a keyword in C. If you're checking for a null pointer, use 0 or the NULL macro.

ok. Narue, you'he really helped me )) thanks! ))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.