recently i am learning exec family.

i want to write a c program that can prompt the user to key in the executable file's path name,file name,arguments.

a example for execl:
execl("/bin/ls","ls","-l",0)

but, obviously, execl cannot fullfil the question. after a long time for me to search to solution, i found execv is a good method.

for example:
char *av[]={"ls","-1",0};
execl("/bin/ls",av);

from the example above i found a idea for my problem:

----------------------------------------------------------------
char pathName[20];//for path name string
scanf("%s",pathName);

int argumentNumber;
scanf("%d",&argumentNumber);// ask the user for number of arguments

char av[argumentNumber][20];//create a 2 dimensional array to store
//the arguments
int i;
for(i=0;i scanf("%s",av[i]);

execv(pathName,av);
------------------------------------------------------------------
please forgive me to ignore the prompting message.

unfortunely, this program is not working.the system call function execv keep failed. this is really disappointed me.

i thought the problem is the NULL character in the execv function, so i add the '\0' into the last position:

*av[argumentNumber]='\0';


but execv still failed to execute.
moreover i tried to display the av array by using for loop, and the string inside is perfectly exist.

execv(pathName,av);

the argument pathName work corrently, but only that two dimesional array av work incorrectly.

this is what i found from internet: int execv(const char *path, char *const argv[]);

my program is supposed to work.......

please help me figure out the reason why execv still failed to execute...

thanks a lot