-
multi array to function
How do I send multi dimentional arrays to functions and output each line in the array and are there different ways to acheive this i,ve got.
void output(char *list);
int main
{
char list[7][70];
/* array filled here */
output(list);
}
void output(char *list)
{
int loop;
for(loop=0;loop<7;loop++)
printf("%s\n",list[loop]);
}
-
void output(char [][70]);
int main
{
char list[7][70];
/* array filled here */
output(list);
}
void output(char list[][70])
{
int i;
for(i=0;i<7;i++)
printf("%s\n",list[i]);
}
-
Code:
void output(char *list);
int main
{
char list[7][70];
/* array filled here */
output(list);
}
void output(char *list)
{
int loop;
int loop2;
for(loop=0;loop<7;loop++)
{
for(loop2=0; loop2<70; loop2++)
{
printf("%c\n",list[loop][loop2]);
}
}
So that's the nested syntax.That prints each char to a separate line.