动态分配内存
#include#include int compare_integers(void const *a,void const *b){ register int const *pa = a; register int const *pb = b; return *pa>*pb ? 1:*pa<*pb ? -1:0;}int main(){ int *array; int n_value; int i; printf("How many values are there?\n"); if(scanf("%d",&n_value)!=1 || n_value<0) { printf("Illegal numbers of values.\n"); exit(EXIT_FAILURE); } array = (int *)malloc(n_value*sizeof(int)); if(NULL == array) { printf("Cant get memery for that many values.\n"); exit(EXIT_FAILURE); } for(i = 0;i