Subversion Repositories wimsdev

Rev

Rev 795 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. /* Prog C qui fournit les reponses a l'exercice Etat_civil.oef .
  5. L'executable doit s'appeler C_etat_civil.o et ĂȘtre place dans
  6. ~/wims/public_html/bin
  7. Ce prog doit etre lance par le script /wims/public_html/bin/sh_etat_civil
  8. */
  9.  
  10. /* Entrees :
  11.         argv[1]= nom du programme (C_etat_civil.o)
  12.         argv[2]= \code_oui1
  13.         argv[3]= \code_oui2
  14.         argv[4]= \code_etat1
  15.         argv[5]= \code_etat2
  16.         argv[6]= \code_celibataire
  17.         argv[7]= reponse1
  18.         argv[8]= reponse2
  19.         argv[9]= \nom
  20. */
  21.  
  22. int main(argc,argv)
  23.         int argc;
  24.         char *argv[];
  25. {
  26.         char code_oui1[4];
  27.         char code_oui2[4];
  28.         char code_celibataire[13];
  29.        
  30.         char reponse1[6];
  31.         char reponse2[7];
  32.         char etat[14];
  33.         char nom[30];
  34.         strcpy(code_oui1,argv[2]);
  35.         strcpy(code_oui2,argv[3]);
  36.         strcpy(code_celibataire,argv[6]);
  37.        
  38.         strcpy(reponse1,argv[7]);
  39.         strcpy(reponse2,argv[8]);
  40.         strcpy(nom,argv[9]);
  41.        
  42.                 /* Les sauts de ligne doivent etre ecrits en html : <br> */
  43.         printf("Etes vous de sexe masculin ?<br>");
  44.         /*scanf("%s",reponse1);*/
  45.         if (strcmp(reponse1,"oui") == 0 || strcmp(reponse1,code_oui1) == 0 )
  46.                 strcpy(etat,"Monsieur");
  47.         else
  48.         {
  49.                 printf("Etes-vous %s?<br>", code_celibataire);
  50.                 /*scanf("%s",reponse2);*/
  51.                 if (strcmp(reponse2,"oui")==0 || strcmp(reponse2,code_oui2)==0  )
  52.                         strcpy(etat,argv[4]);
  53.                 else
  54.                         strcpy(etat,argv[5]);
  55.         }
  56.         printf("Bonjour %s<br>",etat);
  57.         printf("Quel est votre nom ?<br>");
  58.         /*
  59.            Les saisies clavier peuvent ne contenir que deux elements
  60.            si sujet de sexe masculin ayant repondu correctement a la
  61.            premiere question. Alors
  62.            argv[8] contient \nom
  63.            argv[9] contient 0
  64.         */
  65.         if (nom[0]=='0')
  66.                 printf("Au revoir %s %s<br>",etat,argv[8]);
  67.         else
  68.                 printf("Au revoir %s %s<br>",etat,nom);
  69.  
  70.         /*puts(nom);*/
  71.         return 0;
  72. }
  73.        
  74.        
  75.  
  76.  
  77.  
  78.