subscripted value is neither array nor pointer nor vector in c -
how remove error tried everything.... program finding 5 closest number array... in main part take array, num , size , passes through function
void printclosest(int arr[], int x, int n) { int diff[30]; int i,j,k,p,a; (i = 0; < n; ++i) { (j = + 1; j < n; ++j) { if (arr[i] > arr[j]) { = arr[i]; arr[i] = arr[j]; arr[j] = a; } } } for(i=0;i<n;i++) { diff[i]=abs(a[i]-x); } (k = 0; k < n; ++k) { (p = k + 1; p < n; ++p) { if (diff[k] > diff[p]) { = arr[k]; arr[k] = arr[p]; arr[p] = a; } } } for(i=0;i<5;i++) { printf("%d",arr[i]); } }
a
declared int
, yet try use array here:
diff[i]=abs(a[i]-x);