In our assignment, we have to make a sort function using pointers! However, I am having a strange error with mine and I can't seem to figure it out! The populate function generates random numbers for the code, and it works fine.
The sort seems to work okay, but it will take the randomly generated numbers and change them into something like:
Call srand()unsigned)time(NULL)) inside of main(), not the random function. Otherwise, a new seed is initialized each time you call a random number, meaning that they will end up being the same numbers over and over. A simple rule of thumb is that you only need srand called once, so never put it into a function that calls it over and over. I also recommend that you read the first stickied thread in this subforum as to why using system("PAUSE") is bad practice.
void sort(int str)
printf("\n\nThe function is now being sorted in descending order!\n");
int x=0; //initalizes variables
for(int x=0; x<10; x++) //for loop for number of passes
for(int y=0; y<9; y++) //for loop for each pass
if(str[y]<str[y+1]) //if statements that switches numbers if not in proper order