I can not access the array from main in the function. How do i correct this ? Whenever I compile it say the argument 1 is of type **char and the argument 1 passed to fre in incompatible. Do i need to change any syntaxes ?
void fre(char *asd);
int main()
{
char *names[7]={"Jayan Tennakoon","John Long","Robert Lang"};
int i;
for(i=0;i<7;i++)
{
printf("%s\n",names[i]);
}
fre(names);
return 0;
}
void fre(char *asd)
{
int i;
for(i=0;i<7;i++)
{
printf("%s\n",asd[i]);
}
}
void fre(char *asd)-->void fre(char *asd[])orvoid fre(char **asd)frewill look rather likemain(int argc, char *argv[])mainyou havechar *names[7], an array of pointers to char. You attempt to pass this array to functionfre(). Butfreis declared as accepting a single pointer to char. So it doesn't work.