Gives the following discrepancy when printing an array:
Output of last run, given array size of 10:
1054923524,536171146,1590310503,900411369,764853670,471563977,933417110,1800497411,544592671,135121
1054923524,536171146,1590310503,900411369,764853670,471563977,933417110,1800497411,544592671,0,
Any idea why does it prints "0" instead of what I thought? (the last digit of the array)
#include <stdio.h>
#include <stdlib.h>
main() {
srandom(time(NULL));
printf("Size:");
int n;
scanf("%d",&n);
int *ints;
ints=malloc(sizeof(int)*n);
int i;
for(i=1; i<n-1;i++) {
int a=random();
ints[i]=a;
printf("%d,",a);
}
printf("%d\n",ints[n]);
sort(&ints[0],&ints[n]);
free(ints);
}
void sort(int *begin, int *end) {
int i;
for(i=0;&(begin[i])!=end;i++) {
printf("%d,",begin[i]);
}
}