Subversion Repositories wimsdev

Rev

Rev 5505 | 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(int argc, char *argv[])
  23. {
  24.         char code_oui1[4];
  25.         char code_oui2[4];
  26.         char code_celibataire[13];
  27.  
  28.         char reponse1[6];
  29.         char reponse2[7];
  30.         char etat[14];
  31.         char nom[30];
  32.         strcpy(code_oui1,argv[2]);
  33.         strcpy(code_oui2,argv[3]);
  34.         strcpy(code_celibataire,argv[6]);
  35.  
  36.         strcpy(reponse1,argv[7]);
  37.         strcpy(reponse2,argv[8]);
  38.         strcpy(nom,argv[9]);
  39.  
  40.                 /* Les sauts de ligne doivent etre ecrits en html : <br> */
  41.         printf("Etes vous de sexe masculin ?<br>");
  42.         /*scanf("%s",reponse1);*/
  43.         if (strcmp(reponse1,"oui") == 0 || strcmp(reponse1,code_oui1) == 0 )
  44.                 strcpy(etat,"Monsieur");
  45.         else
  46.         {
  47.                 printf("Etes-vous %s?<br>", code_celibataire);
  48.                 /*scanf("%s",reponse2);*/
  49.                 if (strcmp(reponse2,"oui")==0 || strcmp(reponse2,code_oui2)==0  )
  50.                         strcpy(etat,argv[4]);
  51.                 else
  52.                         strcpy(etat,argv[5]);
  53.         }
  54.         printf("Bonjour %s<br>",etat);
  55.         printf("Quel est votre nom ?<br>");
  56.         /*
  57.            Les saisies clavier peuvent ne contenir que deux elements
  58.            si sujet de sexe masculin ayant repondu correctement a la
  59.            premiere question. Alors
  60.            argv[8] contient \nom
  61.            argv[9] contient 0
  62.         */
  63.         if (nom[0]=='0')
  64.                 printf("Au revoir %s %s<br>",etat,argv[8]);
  65.         else
  66.                 printf("Au revoir %s %s<br>",etat,nom);
  67.  
  68.         /*puts(nom);*/
  69.         return 0;
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
  76.