Tuesday, July 28, 2009

Sorting in files c++?

how i could sort records in files but on the same file , i mean i can't create another file to sort in it , the sort must be on the same file and i can use swaping

Sorting in files c++?
can you re-ask your question in english? because you're not making any sense





what exactly is the layout of the file you're sorting?





you can use loops to hold the string you're sorting in a temporary variable, do checks, and then swap them to where you need them to be
Reply:That's going to be tough if they are not fixed sized records.





You can load the file, one record per array element... sort the array, then re-write the file.
Reply:Best solution would be to read each record into an array of records. You would then sort the array however you need and read each array item back into the file.


No comments:

Post a Comment