i want to create a link between two programs throughout the execs functions .
my idea is to create function then point on it by a function pointer then send it to the other program to test it . this is my first programenter code here
1- is this possible ?
2- how ?
i get this idea because i find each time to change the function name in the main function but the remainning still as it was but if i send a pointer function as a character pointer then my programm still as it without changing
#include <iostream>
#include <cstdlib>
#include <unistd.h>
using namespace std;
void 
Random(int* ,const int );
int* 
selection_sort(int *arr ,const int length)
{
    int i = 0,minIndex{0},tmp{0},k{0};
    while(i < length-1) // T(n-1) * C1
    {
        
        minIndex = i;   // Tn * C2
        for(int j = i+1 ; j < length ; j++ )    // som(Ti) from i = 0 to i = length-1 )*C3.
        {
            if((arr)[j] < (arr)[minIndex])
                minIndex = j;
        }
        if(minIndex != i)       // Tn * C4
        {
            
            tmp = (arr)[i];
            (arr)[i] = (arr)[minIndex];
            (arr)[minIndex] = tmp;
        }
        i++;
    }
    
    return arr;
}
void 
Random(int* array,const int length)
{
    srand(time(nullptr));
    int i{-1};
    while(i++ < length)
    {
        array[i] = rand()%100;
        sleep(0.2);
    }
}
int main(int argc,char* argv[])
{
    int* (*ptr)(int*,const int ) = selection_sort;
    execl("/home/hellios/Documents/Algorithms/sort_Algorithms/main",(char*)ptr,0); // complete the call
    return EXIT_SUCCESS;
}
sort_Algorithms/main.c
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
void 
Random(int* array,const int length);
int 
main(int argc,char* argv[])
{
    int* (*ptr)(int *,const int ) =(int* (*) (int*,const int)) argv[1];
    int arr1[100],k{0},*arr;
    Random(arr1,100);
    arr = (*ptr)(arr1,100);
    //selection_sort(arr,100);
    cout<<"out of selection_sort"<<endl;
    for(int j = 0 ; j < 100 ; j++ )
    {
        printf("[%d]\t", arr[j]);
        if(!(++k %10))
            cout<<endl;
    }
    printf("\n");
    
    return EXIT_SUCCESS ;
}
void 
Random(int* array,const int length)
{
    srand(time(nullptr));
    int i {-1};
    while(i++ < length)
    {
        array[i] = rand()%100;
        sleep(0.2);
    }
}
 
    