• [^] # Re: ne pas cumuler >= et size-truc ça fait des noeuds au cerveau :P

    Posté par . En réponse au message integer converter. Évalué à 2. Dernière modification le 08 mars 2019 à 11:55.

    yep je peux aussi jouer.

    #include <stdio.h>
    #include <stdlib.h>
    unsigned int integer_convert(unsigned int *table, unsigned int size) {
     unsigned int *fintab = table + size;
     unsigned int a = *table;
     while( ++table < fintab) {
     if (*table <= 9) {
     a = a*10 + *table;
     }
     else{
     fprintf(stderr, "message d'erreur\n");
     exit(EXIT_FAILURE);
     }
     }
     return a;
    }
    int main(void) {
     unsigned int table[]={1,2,3,4,5,6,7,8,9};
     unsigned int size=9;
     printf("%d\n", integer_convert(table,size));
     return EXIT_SUCCESS;
    }

    bon par contre ça plante pour size < 1 ;)

    Il ne faut pas décorner les boeufs avant d'avoir semé le vent