houksyndrome
Technical User
I have another question. This one is about sorting numbers in an array. I want to write a program that will print out the largest number in an array. I have seen lots of threads about qsort but I'm confused as to how to use it. I have tried writing something like this.
#include <stdio.h>
#include <stdlib.h>
float data[10];
main()
{
data[0]=8.0;
data[1]=7.4;
data[2]=8.6;
data[3]=6.4;
data[4]=20.0;
data[5]=3.4;
data[6]=2.3;
data[7]=13.5;
data[8]=7.7;
data[9]=9.2;
qsort(data, 10, sizeof(float), )
/* I think I need a pointer to a function there, but I don't understand how to use those */
If anybody can help me with this I would be very gratefull. Thanks in advance.
Andrew
#include <stdio.h>
#include <stdlib.h>
float data[10];
main()
{
data[0]=8.0;
data[1]=7.4;
data[2]=8.6;
data[3]=6.4;
data[4]=20.0;
data[5]=3.4;
data[6]=2.3;
data[7]=13.5;
data[8]=7.7;
data[9]=9.2;
qsort(data, 10, sizeof(float), )
/* I think I need a pointer to a function there, but I don't understand how to use those */
If anybody can help me with this I would be very gratefull. Thanks in advance.
Andrew