How can I pass an array of character pointers by reference? I tried passing with &tokens
and de-referencing in func()
but it still won't work.
Here's my code:
#include <stdio.h>
void func(char* tokens[10])
{
char word[10] = "Hello\0";
tokens[0] = word;
}
int main()
{
char* tokens[10];
func(tokens);
printf("%s", tokens[0]);
return 0;
}
Result:
He����