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 / Scoping / esempio3.c < prev   
C/C++ Source or Header  |  1997-04-01  |  381b  |  35 lines

  1. #include<stdio.h>
  2. /* Dichiarazioni nei blocchi */
  3.  
  4. void p1(void)
  5. {  
  6.   
  7.  int x=6;
  8.  
  9.  if (x>0) 
  10.     {
  11.       int x=-2;                 /* dichiarazione interna ad un blocco {...}*/
  12.       if (x<0) printf("%d",x);
  13.     }
  14. }
  15.  
  16. void p2(void)
  17. {
  18.  int y=4;
  19.  int x=0;
  20.  
  21.  printf(" %d",x);
  22.  { int x=y;
  23.    printf(" %d",x);
  24.  }
  25. }
  26.  
  27. void main(void)
  28. {
  29.  p1(); 
  30. /* stampa -2 */
  31.  p2();
  32. /* stampa 0 4 */
  33. }
  34.  
  35.