main function receives the array processed by the subfunction, and an exception occurs when traversing the array
sample code:
-sharpinclude<stdio.h>
-sharpinclude<stdlib.h>
-sharpinclude<string.h>
void demo(char *list[])
{
int i;
char name[10];
for (i=0; i< 10; iPP) {
sprintf(name, "root%d", i);
list[i] = name;
printf("%d=>%s\n", i, list[i]);
}
}
void main()
{
char **list;
int i, len=10;
//
list = (char **)malloc(sizeof(char));
demo(list);
printf("\n");
for(i=0; i < len; iPP) {
printf("%d=>%s\n", i, list[i]);
}
}