When I run this program I get a seg fault when ever I run it and it happen on the last pass through for loop. I put in print statements at one point just to see where the errors were happening and it would go all the way through the for loop and when i=25 it would seg fault at the first assignment. The main thing that confuses me is that it does this no matter what I make the second argument for the for loop.
Code:
int main(int argc, char* argv[])
{
struct LIST map[26];
int i;
for(i=0;i<26;i++){
map[i].startingPoint=' ';
map[i].first=NULL;
}
if(argc>1){
fillStruct(argv[1],map);
printList();
depthSearch();
breadth();
topoSort();
}
else
printf("No file to print");
return 0;
}
int main(int argc, char* argv[])
{
struct LIST map[26];
int i;
for(i=0;i<10;i++){
printf("%d \n",i);
map[i].startingPoint=' ';
printf("%d set to blank",i);
map[i].first=NULL;
printf("%d set to NULL",i);
}
if(argc>1){
printf("Send to fillstruct");
fillStruct(argv[1],map);
printList();
depthSearch();
breadth();
topoSort();
}
else
printf("No file to print");
return 0;
}
Any help will be greatly appreciated.