The code is full of bugs.
You declared a variable length array
long int a[n];
with n elements of the type long int.
Thus in this loop
for(int i=0;i<=n;i++){
scanf("%d",&a[i]);
}
the index i equal to n will be a reason of accessing memory outside the defined array.
Also the conversion specification %d is used for objects of the type int instead of long int.
So the loop must look like
for(int i=0;i < n;i++){
scanf("%ld",&a[i]);
}
Similar problems exist in this for loop
for(int i=0;i<=n;i++){
printf("%d",a[i]);
}
that must be rewritten like
for(int i=0;i < n;i++){
printf("%ld ",a[i]);
}
In this call
sort_array(n,&a[n]);
the second argument expression has the type long int * and points to a non-existent element of the array with the index equal to n. That is the pointer expression points outside the array.
On the other hand, the corresponding function parameter
int sort_array(int n,int *a[]){
in fact has the type int **. The compiler shall issue an error message that the argument expression can not be converted to the type of the parameter.
Also the function has the return type int but returns nothing.
The function should be declared like
void sort_array( long int a[], size_t n );
Due to this for loop
for(int i=1;i<=n-1;i++){
the function will not even try to sort an array containing two elements because this if statement
if(*(a[i])<*(a[j+1])){.
will look like
if(*(a[1])<*(a[1])){
In any case the if statement
if(*(a[i])<*(a[j+1])){
int temp=*(a[j]);
*(a[j])=*(a[j+1]);
*(a[j+1])=temp;
}
does not make a sense. There are compared elements with indices i and j + 1 but there are swapped elements with indices j and j + 1.
Thus the code shall be entirely rewritten. You shall do that yourself.
int *a[]is already wrong; that's synonymous withint **awhich is not what you're providing. (and your indexing inmainandsort_arrayis invoking undefined behavior). You need to turn up your warnings and treat all of them as errors.nelements will have indexes from0ton - 1. If you usenas an index that will be out of bounds and lead to undefined behavior.long int[]inmainbut try to pass along*on to anint**