I am getting a Seg Fault on the 2 lines denoted below. Any ideas why i am getting a seg fault? Any help would be amazing! thanks.
Code:
int** pathArry;
int i;
int count;
printf("-----Allocating Memory-----\n");
pathArry = (int**)malloc(arry1Max * sizeof(int*));
for (int i = 0; i < arry1Max; i++)
{
pathArry[i] = (int*)malloc(arry2Max * sizeof(int));
}
printf("-----Calculating Paths-----\n");
count = 0;
do{
for (i = 0; i <= cities;i++){
if (i == cities){
pathArry[count][i] = 0; // SEGFAULT
}else{
pathArry[count][i] = nodes[i]; // SEGFAULT
}
}
count++;
} while (next_permutation(nodes+1,nodes+cities));