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 / IO / esempio-scanf-errata.c < prev   
C/C++ Source or Header  |  1997-03-08  |  536b  |  26 lines

  1. /* Esempio di input e ouput formattato */
  2.  
  3. #include <stdio.h> 
  4. #define MAX 20
  5.  
  6. /* 
  7.  * La scanf restituisce 1 se l'input e' conforme alla stringa di formato
  8.  * altrimenti restituisce 0.  
  9. */
  10.  
  11. main()
  12. {
  13.   int x;
  14.   char a[2][MAX];  
  15.                     /* 
  16.                      *  Vettore di 2 stringhe, ognuna 
  17.                      *  di lunghezza al piu' MAX
  18.                      */
  19.  
  20.    if (scanf("Rimpiazza %s con %s",&a[0],&a[1])) 
  21.        printf("Ecco, ho messo %s al posto di %s!\n",a[1],a[0]);
  22.    else printf("Input sbagliato"); 
  23. }
  24.  
  25.  
  26.