#include <stdlib.h>
#include <stdio.h>

char *strdup(const char *s); 


void my_strapp(char *src, char **dest){  

    if (src == NULL || dest == NULL) return;
    if (*dest == NULL) return;
    
    //taille src
    int index = 0;
    while (*(src + index)) index ++;
    
    //taille desti
    int index_dest = 0;
    while (*(*dest + index_dest)) index_dest ++;

    //realloc des dest avec la taille de src
    char *new = realloc(*dest, (index + index_dest + 1) * sizeof(char)) ;
    //int *dest = realloc(*dest, index);
    
    if(new == NULL) return;
    *dest = new;

    index = 0;
    /*while(*(new + index_dest)){ 
        
        printf("%c", *(new + index_dest));

        index_dest ++;
    }
    printf("\n");
    //index_dest --;
    while(*(src + index)){

        *(new + (index_dest+ index)) = *(src + index);
        index ++;
    }*/
 
    while(*(src + index)){
        *(*dest + index_dest + index) = *(src + index);
        index ++;
    }

    *(*dest + index_dest + index) = '\0';


}
/*
int main(){
    
    char *src = strdup("World!");
    char *dest = strdup("Hello, ");
    //char *dest = '\0';
    char **dest_ptr = &dest;
    
    my_strapp(src, dest_ptr); // Hello, World!
    printf("%s", *dest_ptr);
    free(src);
    free(dest);
}*/
