Posted by Ryan on 1999-04-19
At 06:14 PM 4/18/99 +0200, you wrote:
>Date: Sat, 17 Apr 1999 12:17:21 -0400
>From: casedeis@xxxxxx.xxx (Case Deis)
>Subject: string manipulation
>
>I'm writing a program in C++. I want it to read records from a file and =
>print them in order of part number or alphabetical order (the user's =
>choice). My question is, what's the simplest way to manipulate strings =
>into alphabetical order when they come from a data file? Thank you.
>
>Shrapnel
>
Well, in C++ you can use letters in boolean comparisons for <> etc, since
it will compare the numeric values of them. I'd say just read the values
from the data file into an array of structures or perhaps just a simple
array or two depending on the complexity of the database, and then do a
bubble sort on it. Since the data is in a file, you can always recreate
the sorted array by re-reading in the values from the file, if they would
change their mind and like to see it a different way. If you are
unfamiliar with the algorithm for a bubble sort, there are examples of them
on many pages on the internet. Try
http://max.cs.kzoo.edu/~abrady/CS400S97/sorting/BubbleSort.html
Hope this helps.
b---------
sender: rdk
aka: emperorx
quote: "Something inside of me - it screams the loudest sound . . ."
e
Previous post | Next post | Timeline | Home