![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2008
Posts: 7
Rep Power: 0
![]() |
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
c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 346
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#3 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
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.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jan 2008
Posts: 7
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2008
Posts: 7
Rep Power: 0
![]() |
c++ Syntax (Toggle Plain Text)
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 []' |
|
|
|
|
|
#6 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
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
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jan 2008
Posts: 7
Rep Power: 0
![]() |
Re: String Selection Sort
c++ Syntax (Toggle Plain Text)
haha ok now ive got everything working it just seems to not want to sort the names (X_X) Last edited by gmann145; Apr 1st, 2008 at 12:07 PM. |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Apr 2008
Posts: 10
Rep Power: 0
![]() |
Re: String Selection Sort
None of your loops actually ever run:
c++ Syntax (Toggle Plain Text)
You make i=0 and the loop only runs if i>17. |
|
|
|
|
|
#9 |
|
Not a user?
Join Date: Sep 2007
Posts: 308
Rep Power: 2
![]() |
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.
|
|
|
|
|
|
#10 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,198
Rep Power: 5
![]() |
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.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| An Attempt at a DBMS | grimpirate | PHP | 8 | Apr 17th, 2007 2:01 PM |
| Throwing an exception when using string constructor | csrocker101 | C# | 3 | Apr 8th, 2007 3:04 PM |
| Help with breaking apart a string | csrocker101 | C# | 6 | Apr 6th, 2007 8:50 AM |
| Function Parameters | grimpirate | PHP | 10 | Mar 14th, 2007 7:55 PM |
| selection sort | hopeolicious | C++ | 2 | Mar 15th, 2005 1:47 AM |