#include #include void afficherTableauInt(int* t, size_t taille) { for (int i = 0; i < taille; i++) { printf("%10d", t[i]); } printf("\n"); } int main(void) { size_t taille1 = 3; size_t taille2 = 5; size_t taille3 = 2; int* ptr = (int*) malloc(taille1 * sizeof(int)); int* tmp; if (ptr == NULL) { printf("Allocation avortee\n"); exit(1); } printf("Allocation reussie a l'adresse : %p\n", ptr); for (int i = 0; i < taille1; i++) { ptr[i] = i; } afficherTableauInt(ptr, taille1); printf("\n"); tmp = (int*) realloc(ptr, taille2 * sizeof(int)); if (tmp == NULL) { printf("Reallocation avortee\n"); exit(2); } ptr = tmp; printf("Reallocation reussie a l'adresse : %p\n", ptr); afficherTableauInt(ptr, taille2); printf("\n"); tmp = (int*) realloc(ptr, taille3 * sizeof(int)); if (tmp == NULL) { printf("Reallocation avortee\n"); exit(3); } ptr = tmp; printf("Reallocation reussie a l'adresse : %p\n", ptr); afficherTableauInt(ptr, taille3); return 0; }