When I try to compile the following code I receive an error: "Type error in argument 1 to 'allocate'; found 'char * *', expected 'char *" at the line indicated (<<<<<). Explanations would be appreciated.
#include <stdio.h>
#include <string.h>
void allocate(char *dt);
int main(void)
{
char *data[3];
allocate(data); <<<<<
return 0;
}
void allocate(char *dt)
{
int i;
char buf[] = "A test string";
for (i = 0; i < 3; i++){
strcpy(&dt[i], buf);
printf("%s\n", dt[i]);
}
}
My understanding is that I should call allocate thus: allocate(&data) but with this I receive the following error: "Type error in argument 1 to 'allocate'; found 'char * (*)[3]', expected 'char *'".
It should be obvious that I am trying to make the contents of *data[] == buf.