![]() |
String Selection Sort
hey all,, i have to use a selection sort function to search an array of strings, this is what ive got so far, im not sure where to put the selectionSort in the main and so still unsure if its correct
:
|
Re: String Selection Sort
May just be me, but I have no clue what you are trying to actually achieve.
Can you post some examples of what the results should be and that may make it clearer what you are trying to do, and what your question is. |
Re: String Selection Sort
You probably want to call it after you've declared your list of strings. And then afterwards, either have a function to verify that it's sorted correctly, or print the sorted array and manually verify.
|
Re: String Selection Sort
basically the program is supposed to print the names of the array out in alphabetical based on the first name that you see, which happens to be their last for example:
Allen, Jim Holland, Beth |
Re: String Selection Sort
:
some work of i've added since starting, i keep getting an error that says cannot convert parameter 1 from 'char [20][17]' to 'char []' |
Re: String Selection Sort
Quote:
For future reference, please provide a line number with errors; makes it easier for us to find out where they are :icon_wink: |
Re: String Selection Sort
:
haha ok now ive got everything working it just seems to not want to sort the names (X_X) |
Re: String Selection Sort
None of your loops actually ever run:
:
You make i=0 and the loop only runs if i>17. |
Re: String Selection Sort
actually, it will run once 17 is exceeded; if that ever happens. I haven't looked at the code to see.
|
Re: String Selection Sort
Quote:
volatile, I don't see this happening, as the value would probably be cached in a register. In fact, given the lack of the volatile keyword as a clue to the compiler, any intelligent optimizer would probably eliminate the loop entirely. |
| All times are GMT -5. The time now is 5:00 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC