I wrote and ran this code to practice the basic algorithm. but this program operation is stopped. What is the problem?
#include <stdio.h>
#include <stdlib.h>
int bans(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
int main()
{
int m, i;
int* arr;
scanf("%d", &m);
arr = (int*)malloc(sizeof(int) * m);
for (i = 0; i < m; i++) {
scanf("%d", arr[i]);
}
int n = sizeof(arr)/sizeof(arr[0]);
for (i = 0; i < n; i++) printf("%d ", arr[i]);
qsort(arr, n, sizeof(arr[0]), bans);
for (i = 0; i < n; i++) printf("%d ", arr[i]);
free(arr);
return 0;
}