I am wondering why the below produce different results:
char *const temp[] = {"cal","4","2019",NULL};
execvp(temp[0],temp);
perror("Return from execlp not expected");
exit(EXIT_FAILURE);
when executed will produce a calendar with ONLY the month april
char *const temp[] = {"cal"};
char *const temp2[] ={"4","2019",NULL};
execvp(temp[0],temp2);
perror("Return from execlp not expected");
exit(EXIT_FAILURE);
when executed will produce a calendar with ALL the months
I want to get the second form to work correctly, as for my problem i have 2 arrays, one to store all my commands, and the other to store all my arguments for the command. eg
array1[0] = command
array2[0] = arg1 ar2 arg3 // the arguments for the command in array1[0]
And within a loop until i hit the end of my command array use fork and excute these commands in a child class so that i can go through and execute all the commands in the array.
As per execvp man