/* sorts an array of integers using selection sort */ #include #include typedef int *LIST_PTR; void swap(int *a , int *b); int find_min_pos(int list[], int size, int start_pos); void sel_sort(int list[], int size); void fget_list(LIST_PTR *list, int *count) ; int main(void) { int i,count; LIST_PTR list; fget_list(&list, &count); sel_sort(list,count); for(i = 0; i < count; i++) printf("%d ", list[i]); free(list); return 0; } /* reads all the integers in the file integer.dat into a dynamic array */ void fget_list(LIST_PTR *list, int *count) { FILE *inp; int n; LIST_PTR p; int cnt=0,i; inp=fopen("a:\\integers.dat","r"); while (!feof(inp)) { fscanf(inp,"%d",&n); cnt++; } rewind(inp); p=(LIST_PTR)malloc(cnt*sizeof(int)); for (i=0; i