I am trying to initialize an array of pointers but when i try to print it in the main it don't work, It shows an segmentation fault but if i try to print it in the same method it do print
here is my code
typedef struct File
{
char fileName[Max_FILE_NAME_LENGTH];
char *listOfFiles[];
}File;
File dependencies[MAXIMUM_FILES];
void findListOfFiles(char *line, int i, int currDepend)
{
int idx=0,numOfFiles=0;;
while(line[i]!='\n')
{
char *name=(char *)malloc(65*sizeof(char));
while(line[i]!=',' && line[i]!='\n')
{
name[idx]=line[i];
i++;
idx++;
}
name[idx]='\0';
dependencies[currDepend].listOfFiles[numOfFiles]=name;
printf("%s+", dependencies[currDepend].listOfFiles[numOfFiles]);
if(line[i]=='\n')
{
if(name){
free(name);
name=NULL;
}
break;
}
if(name){
free(name);
name=NULL;
}
numOfFiles++;
i++;
idx=0;
}
}