home *** CD-ROM | disk | FTP | other *** search
/ ftp.disi.unige.it / 2015-02-11.ftp.disi.unige.it.tar / ftp.disi.unige.it / pub / .person / CataniaB / teach-act / esempi / Strutture_Union / struct.c next >
C/C++ Source or Header  |  1997-04-06  |  518b  |  37 lines

  1. #include <stdio.h>
  2.  
  3. struct   punto   
  4.   { 
  5.     float x; 
  6.     float y;
  7.   } Q;       
  8.  
  9. struct punto P={0.0,0.0};
  10.  
  11. struct   cerchio  
  12.   {
  13.     struct punto  Centro;  
  14.     float         Raggio;
  15.   } E;
  16.  
  17. struct cerchio C={{1.4,5.7},6};  /* inizializzazione complessa */
  18.  
  19. /* struct cerchio D={P,7};   Errore in compilazione! P non e' una costante */ 
  20.  
  21. main()
  22. {
  23.  
  24.  
  25.  E.Centro=P; 
  26.                   /* oppure */
  27.  E.Centro.x=P.x; 
  28.  E.Centro.y=P.y; 
  29.  
  30.  E.Raggio=0; 
  31.  
  32.  C=E;
  33.  
  34.  printf("\n %f %f %f",E.Centro.x,E.Centro.y,E.Raggio); 
  35.  
  36. }
  37.