![]() |
execv in unix prob.
Hi to all
Pls, help me in solving the problem execv() function. My working environment is Solaris and solaris c compiler. Can any one tell me how to use execv() function in c. Following is the sample code: main() { char a[][60]={"sample.sh", "one", "two", "three"}; execv("sample.sh", a); } but it gives error like "Bad Address" Pls can any one help me out in this regard. Thanks in advance |
Re: execv in unix prob.
Because a should be an array of pointers, not an array of arrays.
Code:
char *a[] = { "sample.sh", "one", "two", "three", NULL }; |
Re: execv in unix prob.
Thanks a lot Salem...........
Could you pls explain me what is the difference between char [][] and char *[]. |
Re: execv in unix prob.
The first is an array of arrays, the second is an array of pointers.
Compare the results of trying strlen(a[0]) and sizeof(a[0]) for both ways of declaring the array. |
Re: execv in unix prob.
Thanks Salem.
I got your point. But my question is that What is the problem to use the char [][] instead of char *[] in the execv() system call. Thanks in advance.... |
Re: execv in unix prob.
Well it expects an array of pointers, what more is there to understand?
They're not the same thing. Code:
An array of arraysJust because you can do printf("%s", a[i] ); does NOT make them the same thing, because the compiler will generate slightly different code depending on how you declared the array to begin with. |
| All times are GMT +5.5. The time now is 08:14. |