Differences between ...

Hello, I wanna know the differences between these,:

void calculate (char *x) void calculate (char **x)


And these:
void calculate (char *x) void calculate (char x[]) void calculate (char *x[])

Im confused about them, so thanks in advance for any answer!
The first function has a pointer. The second has a pointer to a pointer.

Number four, array, behaves rather similarly to the pointer version.

The last has a pointer to an array, so resembles pointer to pointer
Arrays cannot be passed to functions, so whenever you see [brackets] as a parameter, it's actually passing a pointer. Therefore... these two are identical:

void calculate(char *x) and void calculate (char x[])

They both have a pointer to a char.


And these two are also identical:
void calculate(char **x) and void calculate( char *x[] )

They both have a pointer to a pointer to a char.
And how do I know when to user a pointer to a pointer?
If you need to change the value of the pointer pointed to but can't use references for some reason (e.g. working with a C library). This is more preferable:

void f(char *&c)
Topic archived. No new replies allowed.