Developpement/23DEV1.1/TPS1/TP2/controle/CM2_2022/main.c

39 lines
772 B
C

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "Repetition.h"
int main(int argc, char *argv[]) {
int taille = argc - 1;
int i;
long *tableau = malloc(taille * sizeof(long));
bool resultat = 0;
if (argc < 2) {
fprintf(stderr, "Usage: %s <entiers...>\n", argv[0]);
return EXIT_FAILURE;
}
if (!tableau) {
perror("Erreur d'allocation de mémoire");
return EXIT_FAILURE;
}
for (i = 1; i < argc; ++i) {
tableau[i - 1] = strtol(argv[i], NULL, 10);
}
resultat = sont_identiques(tableau, taille);
if (resultat) {
printf("valeurs identiques\n");
} else {
printf("valeurs non identiques\n");
}
free(tableau);
return EXIT_SUCCESS;
}