I am calling a shell script from a \'c\' program and have some variables in c which I would like to pass as arguments to the shell script. I tried using the system() to call
shell script (a.sh):
# iterates over argument list and prints
for (( i=1;$i<=$#;i=$i+1 ))
do
echo ${!i}
done
C code:
#include
int main() {
char arr[] = {'a', 'b', 'c', 'd', 'e'};
char cmd[1024] = {0}; // change this for more length
char *base = "bash a.sh "; // note trailine ' ' (space)
sprintf(cmd, "%s", base);
int i;
for (i=0;i