L111 : invalid types for array subscript

Code:#include <stdio.h> #include <time.h> #include <math.h> #include <stdlib.h> typedef struct { int x; int y; }city; permute(city *a,int n,int t,int **d,int *b) { int i,j,temp1,temp2; if(n==1) { for(j=0;j<t-1;j++) (*b) += d[j][j+1]; (*b) += d[j][0]; b++; } else { for(i=1;i<n;i++) { temp1 = (a+i)->x; temp2 = (a+i)->y; (a+i)->x = (a+(n-1))->x; (a+i)->y = (a+(n-1))->y; (a+(n-1))->x = temp1; (a+(n-1))->y = temp2; permute(a,n-1,t,d,b); temp1 = (a+i)->x; temp2 = (a+i)->y; (a+i)->x = (a+(n-1))->x; (a+i)->y = (a+(n-1))->y; (a+(n-1))->x = temp1; (a+(n-1))->y = temp2; } } } minimum(int *b, int n) { int min; for(int i=n-2;i<=0;i++) if(*(b+i)<min) min = *(b+i); printf("Minimum cost for the trip is %d\n\n",min); } int main() { int n; printf("How many cities you want to travel (include the starting position ,too, in your number)\n\n"); scanf("%d",&n); city *a; a=(city *)malloc(n*sizeof(city)); printf("\n\nAssume the x and y co-ordinate of the city from where you start(or end) the journey to be (0,0)\n\n"); a->x=0; a->y=0; printf("Data stored for the city from where you start\n\n"); printf("Now ,storing x and y co-ordinate of the other cities (random value)\n\n"); printf("press enter to randomly generate the co-ordinates....."); srand((unsigned)time ( NULL ) ); for(int i=1;i<n;i++) { (a+i)->x= 0 + rand()%1000; (a+i)->y= 0 + rand()%1000; } printf("\n\nData storing successful for other cities\n\n"); printf("Now, sorting the cities with respect to their x co-ordinates\n\n"); printf("press enter to sort the cities......"); int temp1,temp2; for(int j=0;j<n-1;j++) for(int k=j+1;k<n;k++) { if((a+j)->x > (a+k)->x) { temp1 = (a+j)->x; temp2 = (a+j)->y; (a+j)->x = (a+k)->x; (a+j)->y = (a+k)->y; (a+k)->x = temp1; (a+k)->y = temp2; } } printf("\n\ncities with respect to their x co-ordinate is sorted\n\n"); int d[n][n]; printf("calculating the distance between the cities\n\n"); printf("press enter to calculate and store....."); int m,l,g; for(l=0;l<n-1;l++) for(m=l;m<n;m++) d[l][m] = (int) sqrt(pow(((a+l)->x - (a+m)->x),2) + pow(((a+l)->y - (a+m)->y),2)); for(l=1;l<n;l++) for(m=0;m<l;m++) d[l][m] = d[m][l]; printf("\n\nDistances calculated and stored\n\n"); int fac,min; fac = 1; for(g=1;g<=n-1;g++) fac *= g; fac +=1; int *b; b =(int *)malloc(fac*sizeof(int)); permute[a,n,n,d,b]; minimum[b,fac]; }