Take the tour ×  I tried to write an function that sorts arrays
using pointers. My p pointer points to x array but why should I
return x as a pointer?      #include <stdio.h>     int sort(int
x[], int n){     int *p,k;         for(int l=i+1; l<n; l++){
return *x; int main(){     int n;     scanf("%d", &n);     int
a[n];     return 0; share|improve this question Why are you
returning anything? You don't use it. –  Duck Nov 10 '12 at 2:13
I used it there. sort(a,n); –  bbilegt Nov 10 '12 at 2:15 No,
you are throwing it away. if it was something like ret =
sort(a,n) you would be using it. –  Duck Nov 10 '12 at 2:16 add
comment  2 Answers  up vote 3 down vote accepted  your function
returns an int (value), not a pointer. your implementation
(return *x;) returns the first element of parameter x[] by
value.  why should I return x as a pointer?  what is the return
value supposed to indicate? it's not clear why you would return
anything in this scenario. until you can answer that, void would
be better.  share|imp