I have an array x of floating point numbers (of variable length n) which I want to pass to a shell script as command line arguments using execl(). I suppose I need to declare a pointer to a char array **args[] and then dynamically allocate this to have the length n and then do something like this:
*args=malloc(n*sizeof(char[]);
for(i=0;i<n;i++) sprintf( args[i] , "%f", x[i]);
execl("script.sh","script.sh", args, NULL);
However, I cannot get the allocation of args to work right. Could someone please hint at how this is done correctly?