Révision 180
Ajouté par Ely SENE il y a environ 3 ans
main.c | ||
---|---|---|
{
|
||
if(trame[j+1]!=type[j])
|
||
{
|
||
comp=0;
|
||
comp=0; //Si les chaines de caract?res sont diff?rentes on retourne 0
|
||
}
|
||
j++;
|
||
}
|
||
... | ... | |
return i;
|
||
}
|
||
|
||
//fonction retournant uniquement les n premier chiffres dans un nombre.
|
||
int decode_nombre(char * ch,int n)
|
||
{
|
||
int i=0;
|
||
int nbr_return=0;
|
||
while (i<n)
|
||
{
|
||
nbr_return = nbr_return*10 + decode_int(ch[i]);
|
||
i=i+1;
|
||
}
|
||
return nbr_return;
|
||
}
|
||
|
||
//Fonction ? modifier !!!!!
|
||
void traitement(char * trame)
|
||
{
|
||
... | ... | |
printf ("> %s\n",trame);
|
||
}
|
||
|
||
int trame_cmp(char*trame, char*type)
|
||
{
|
||
int i;
|
||
int verif=1;
|
||
for(i=0;i<5;i++)
|
||
{
|
||
if (trame[i+1]!=type[i])
|
||
{
|
||
verif=0;
|
||
}
|
||
}
|
||
return verif;
|
||
}
|
||
|
||
|
||
//Ajouter vos tests unitaires dans cette fonction.
|
||
... | ... | |
{
|
||
printf ("Erreur Test unitaire decode_int.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("98765",2)!=98)
|
||
{
|
||
printf ("Erreur Test unitaire decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("7456",3)!=745)
|
||
{
|
||
printf ("Erreur Test unitaire decode_nombre.\n");
|
||
exit(-1);
|
||
}
|
||
if (decode_nombre("123456789",3)!=123)
|
||
{
|
||
printf ("Erreur Test unitaire decode_nombre.\n");
|
||
exit(-1)
|
||
}
|
||
|
||
// Ne pas modifier cette fonction
|
||
... | ... | |
while ((trame = trame_suivante()))
|
||
traitement(trame);
|
||
|
||
return 0;
|
||
}
|
||
return 0;
|
||
}
|
||
|
Formats disponibles : Unified diff
Fonction decode nombre et test_decode_nombre()