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

39 lines
772 B
C
Raw Permalink Normal View History

2024-12-09 11:53:11 +01:00
#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;
}