??? 07/06/08 22:46 Read: times |
#156442 - thanks guys.... Responding to: ???'s previous message |
To all,
I've been using unsigned char for so long that I didn't realize that I should used have just made is a plain old char since its beaten to death to keep the code as small as possible by using unsigned. I ran it as just char and all is right with the world. Hopefully this may help someone in the future as it works exactly as it should. Thanks again all, Best Chris void bubbleSort(char my_array[], char array_size); //prototype char small_array[5] = {9,4,2,8,3}; //my array initialized out of order void bubbleSort(char my_array[], char array_size) //sort it { char i, j, temp; for (i = (array_size - 1); i >= 0; i--) { for (j = 1; j <= i; j++) { if (my_array[j-1] > my_array[j]) { temp = my_array[j-1]; my_array[j-1] = my_array[j]; my_array[j] = temp; }}}} void main (void)//main program { while(1)//Loop this section forever { bubbleSort(small_array, 5); //sort forever test } } |
Topic | Author | Date |
Compile error using a bubble sort | 01/01/70 00:00 | |
Is the array 'uchar' or is it 'int'? Do not mix. | 01/01/70 00:00 | |
argument consistency | 01/01/70 00:00 | |
I had one error and type mismatch seen | 01/01/70 00:00 | |
more careful with decrement unsigned char | 01/01/70 00:00 | |
Use different identifiers for global and auto | 01/01/70 00:00 | |
Yes I saw the corruption... | 01/01/70 00:00 | |
You can use any type you like. | 01/01/70 00:00 | |
thanks guys....![]() | 01/01/70 00:00 |