| mothergoose729 (29) | ||||||||||
|
I have a project for my data structure class, and on of the things I have to add to my class is a read and write function. I need to be able to read from a text file supplied by my instructor and be able to write out to a text file the strings sorted. The input file is structured so that there are two strings on each line, with the first being the "key" and the item I must sort, and the second being the data which the unique key corresponds to. Something like: (key) (data) 12345678 I go to the store The strings ASCII characters are read in from a file and my STRING class object is set to be equal to these read in characters. My STRING class is more or less the same (at least conceptually) as the built in string type. STRING.h
STRING.cpp
main.cpp
output
CISP430records2.dat is not in my program directory. The file I am supposed to be reading from I have uploaded here, as well as an example of a sorted keys file provided by my instructor. Its pretty big as it has a lot of data in it. CISP430.dat <- input file http://www.mediafire.com/?jeu646d03jv461d DEFSortedKeys.txt <-output file http://www.mediafire.com/view/?bddvgxz1b5widdd The input file is titled "CISP430.dat". Its first four entries copied from word pad:
Example output file called "sorted keys". I need to be able to write a file that looks like this one:
I know that operator << for ostream is the way it is supposed to be, and that operator >> for istream is good enough. These I have confirmed by my instructor. I don't know how to write the read and write functions. Its really a syntax issues, because I don't know which commands to issue and I don't know how to "catch" the passed file name for both reading and writing. What I have in my cod e compiles but doesn't work. This is a small part of a larger project I need to complete. I really don't know how to go about doing this one part. I appreciate any help at all, in the form of instruction or links to some pages on the topic. Thank you so much. My full STRING class I have uploaded here: http://www.mediafire.com/?oj5dbkn3ajqbedp http://www.mediafire.com/?javc9ku2kumu5te http://www.mediafire.com/?o6c38dhbqoqrcmd | ||||||||||
|
Last edited on
|
||||||||||
| mothergoose729 (29) | |
| Anybody? Need help reading and writing from ostream/istream. | |
|
|
|