1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
int i;
int a,m,j;
char date[11],date2[11];
fgets(date,11,stdin); /*purger l'entree et verifier que la saisie est conforme*/
for(i=0; (unsigned)i<strlen(date); i++)
if (!isdigit(date[i])) date[i]=' ';
sscanf(date,"%d%d%d",&j,&m,&a);
printf("%2d/%2d/%4d\n",m,j,a); /*affichage seulement*/
sprintf(date2,"%2d/%2d/%4d\n",m,j,a); /*ecriture dans une chaine de caracteres*/
printf("%s\n",date2);
return 0;
} |
Partager