Advertisement
salahgo

Saisie/Affichage date (defstruct)

Sep 26th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. struct da
  4. {
  5. int jour;
  6. int mois ;
  7. int annee;
  8. };
  9.  
  10. typedef struct da date;
  11. void saisie (date *d);
  12. void affiche (date *d)
  13. {printf ("%d / %d / %d \n",d->jour ,d->mois ,d->annee);
  14. }
  15.  
  16. main()
  17. {
  18.     date *d1;
  19.     d1=(date*) malloc (sizeof(date));
  20.     saisie(d1);
  21.     affiche(d1);
  22.     date d2;
  23.     saisie(&d2);
  24.     affiche(&d2);
  25. }
  26.  
  27. void saisie (date *d)
  28. {
  29. do{
  30. printf ("jour \n");
  31. scanf("%d",&(d->jour));}
  32. while (d->jour <1||d->jour>31);
  33. do{
  34. printf("mois \n");
  35. scanf ("%d",&(d->mois));}
  36. while (d->mois <1||d->mois>12);
  37. printf("annee \n");
  38. scanf ("%d",&(d->annee));
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement