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

char **insert_string(char **strings_array, int *array_size, char *insert_str, int index){

    
    char **rslt = malloc((*array_size + 1 )* sizeof(char *));
    if(rslt == NULL) return NULL;

    int index_clc = 0;
    int index_clc2 = 0;
    //char *temp;

    while (index_clc < *array_size + 1){

        
        if (index_clc == index) *(rslt + index_clc) = insert_str;
        else{
            *(rslt + index_clc) = *(strings_array + index_clc2);
            index_clc2 ++;
	}

        /*
        if (index_clc >= index){
            temp = *(strings_array + index_clc);
            *(rslt + index + 1) = *(strings_array + index);
        }*/

        index_clc ++;
    }
    //*(rslt + index_clc) = temp;
    //*(strings_array + index) = insert_str;
    
    //free(temp);
    *array_size = *array_size + 1; 
    return rslt;
}
/*
int main(){
    char *tests[] = {"This", "is", "a", "long", "example"};
    char *ins = "very";
    int ted = 5;
    
    char **rslt = insert_string(tests, &ted, ins ,3);
    
    if(rslt != NULL){
	
	for (int i = 0; i < ted; i ++) printf("%s",rslt[i]);
    }
    printf("\n");
    
    free (rslt);
}
*/
