// Bsp14.cpp : Definiert den Einsprungpunkt für die Konsolenanwendung.
//

#include "stdafx.h"

#include "family.h"
int main(int argc, char* argv[])
{
  struct famil familie[5], *f;
  struct persn person[20], *p;
  struct adresse adr[20], *a;
  register unsigned short i;
  char Q1[10],Q2[10],Q3[10];
  int d = 0;

  familie[0].sohn = familie[1].mann = &person[0];
  familie[0].tochter = familie[3].frau = &person[9];
  familie[1].tochter = familie[2].frau = &person[1];
  familie[0].mann = &person[3];
  familie[0].frau = &person[4];

  familie[1].frau = &person[6];
  familie[1].sohn = &person[2];
  familie[2].sohn = &person[7];
  familie[2].tochter = &person[8];
  familie[0].mann = &person[3];
  familie[3].mann = &person[10];
  familie[3].sohn = &person[11];
  familie[3].tochter = &person[12];


  person[0].fl = &familie[0];
  person[1].fl = &familie[1];
  person[2].fl = &familie[2];
  person[3].fl = &familie[0];
  person[4].fl = &familie[0];
 /* person[5].fl = &familie[2];
  person[6].fl = &familie[1];
  person[7].fl = &familie[2];
  person[8].fl = &familie[2];
  person[9].fl = &familie[3];

  person[10].fl = &familie[3];
  person[11].fl = &familie[3];
  person[12].fl = &familie[3]; */

  for (i = 0; i < 5; i++)
  {
	  person[i].ad = &adr[i]; 
	  
	  printf("P%i f0.sn=f1.mn:", i);
	  scanf("%s %s %d %s %d %ld %s",person[i].name, person[i].vname, &(person[i].alt),\
		  adr[i].strasse, adr[i].hausnummer, adr[i].plz, adr[i].ort);

  }

//  printf("familie[0].sohn=%s == familie[1].mann=%s person[0]=%s \n",
//	      (familie[0].sohn)->name,  (familie[1].mann)->name, person[0].name);
//  printf("Familie der person[7] = %s", (person[7].fl)->mann->vname);

printf("\n\nAnfrage lautet:\n FamilieNr.");
scanf("%d", &d);
f = &familie[d];
printf("Fa.Member:");
scanf("%s", Q1);
f = !strcmp("sohn", Q1) ? f->sohn->fl : !strcmp("tochter", Q1) ? f->tochter->fl : f->frau->fl;
printf("Fa.Member:");
scanf("%s", Q2);
p = !strcmp("sohn", Q2) ? f->sohn : !strcmp("tochter", Q2) ? f->tochter : f->frau;
printf("Attribute:");
scanf("%s", Q3);

printf("Familie%d->%s->%s->%s\n", d,Q1,Q2,Q3);
printf("%s", p->name);









  return 0;
}
