I have a char array. I take its address and pass it to a function which accepts a double char pointer:
char result[1024+1];
memset(result, 0, sizeof(result));
executeGetQuery(query, &(result));
Function definition: int executeGetQuery(char * query, char ** queryResultData)
I get this compile time error
warning: argument #2 is incompatible with prototype:
prototype: pointer to pointer to char : line 1531
argument : pointer to array[1025] of char
I’ve always passed arrays as pointers in C before. Why am I getting this error? Is my compiler to blame?
EDIT: What is the fix?
EDIT2: I want the function to write something to the result array which is why I am passing a char** instead of char*. What is then another way, the way, to have a function write to a param which I pass in?
In this case (you don’t need the
char **) usechar *both in the prototype and the calling codeI’d also include a size argument for protecting against buffer overflows
Edit:
to change the contents of the array do something like
You can see the change in the calling function