I'm having trouble setting this up correctly, could someone point out my errors ?
Code:
#include <stdio.h>
double arrayOne[] = {2.3, 5.9, 2.7, 1.9, 3.6, 8.10},
arrayTwo[] = {6.1, 0.2, 3.5, 2.8},
arrayOutput[20];
int cmpfunc (const void * a, const void * b)
{
return ( *(double*)a - *(double*)b );
}
int main(void){
int k;
printf("SORT AND UNIFY ARRAYS\n\n");
printf("Prior to sorting arrayOne look like this ");
for(k = 0; k < 6; ++k)
printf("%.1f ", arrayOne[k]);
qsort(arrayOne, 6, sizeof(double), cmpfunc);
printf("\n\nAfter sorting arrayOne looks like this ");
for(k = 0; k < 6; k++)
printf(" %3.1f", arrayOne[k]);
return 0;
}
results from running it
SORT AND UNIFY ARRAYS
Prior to sorting arrayOne look like this 2.3 5.9 2.7 1.9 3.6 8.1
After sorting arrayOne looks like this 1.9 2.7 2.3 3.6 5.9 8.1