Possible Duplicate:
Should I use char** argv or char* argv[] in C?
What is the difference between using char **argv and char *argv[] for the second parameter to a c program. Does it affect the way the strings are passed? Thanks :-)
There is absolutely no difference. At all.
in C
void f(int*);
and
void f(int[]);
and
void f(int[42]);
are three completely identical declarations.
**argv and *argv[] as a function argument are technically identical - as C will convert any array into a pointer in a function argument.
Note that this can catch you out, for example this is totally valid and won't raise any warnings (or errors), even though a beginner might think that the array passed is invalid:
void func(int array[2])
{
array[1] = 1; // buffer overrun: will write past the end of a[].
}
int main()
{
int a[1];
func(a);
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With