In C I need to generate 100 random numbers and then sort them in descending order. As of now, I have this, and it is an absolute mess. I can tell I am going about it all wrong but am not experienced enough to actually be able to write this in a sane manner. Can anyone help?
/*100 random numbers in range 1-10*/
/*sorted in descending order*/
#include <stdio.h>
void random(char *nums, int count);
int main(void) {
int random_num, count;
char nums[100];
for(count = 0; count < 100; count++) {
random(&nums, count);
}
for(count = 0; count < 100; count++) {
printf("%d\t", nums[count]);
}
return 0;
}
void random(char *nums, int count) {
int random_data = fopen("/dev/random", "r");
nums[count] = fread[random_data];
}