I have an interface (.cpp),header(.h) and implementation(.cpp)
The interface does the input/output.
The header writes the class and it's member functions:
The implemetation does the sorting.
My input file (.txt)is a list of books in the format:
catalogue_number, author_last_name,author_first_name, book_title,genre,availabilty.
*The catalogue number are 4 digits.
I need to sort the author_last_name using an array and output in file(.txt)
I needed help seperating into the three files, outputing and inputing from the file and using arrays to sort rather than vector.
int main()
{
const string strFile = "input2.txt";
ifstream is(strFile.c_str());
vector<SBooks> vInput;
// This copies SBook objects into a vector from file input.txt
copy(istream_iterator<SBooks>(is), istream_iterator<SBooks>(), back_inserter(vInput));
cout << "Read in records unsorted: \n";
// This prints the read in output to the screen.
copy(vInput.begin(), vInput.end(), ostream_iterator<SBooks>(cout, "\n"));
// This performs the sorting
sort(vInput.begin(), vInput.end(), comp);
// This prints the sorted output to the screen.
cout << "Sorted: \n";
copy(vInput.begin(), vInput.end(), ostream_iterator<SBooks>(cout, "\n"));
return 0;
}