![]() |
|
![]() |
|
|
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 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 135
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 |
|
Expert Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 706
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 | |
|
Expert Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 706
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 11:07 AM. |
|
|
|
|
|
#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: 190
Rep Power: 1
![]() |
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 | |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 864
Rep Power: 3
![]() |
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.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
![]() |
| 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 1:01 PM |
| Throwing an exception when using string constructor | csrocker101 | C# | 3 | Apr 8th, 2007 2:04 PM |
| Help with breaking apart a string | csrocker101 | C# | 6 | Apr 6th, 2007 7:50 AM |
| Function Parameters | grimpirate | PHP | 10 | Mar 14th, 2007 6:55 PM |
| selection sort | hopeolicious | C++ | 2 | Mar 15th, 2005 12:47 AM |