Hi, i'm having a problem on how to print the names in alphabetical orders using the vector. here's the code.. please help me :(
void Record2::view(vector<string> words, int x) //VIEWING THE RECORD'S LIST
{
setcolor(14); system("cls"); infile.open("AddressBook.txt"); //opening the file for reading only
rec.DisplayDate();
setcolor(15); cout << "\n____________________________________________________________________________________ADDRESS BOOK RECORD______________________________________________________________________________________\n\n";
cout << " Full Name: Contact Number: E-Mail Address: Address:";
cout << "\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n";
if (infile.is_open()) // verifying if file is open perform the instructions below
{
while (getline(infile, record.fullname), getline(infile, record.contact), getline(infile, record.email), getline(infile, record.address)) //reading the strings inside the text file
{
words.push_back(record.fullname);
for (vector<string>::iterator i = words.begin(); i != words.end(); i++){
setcolor(9); cout << setiosflags(ios::left) << setw(1) << ++x;
cout << setiosflags(ios::right) << setw(31) << *i;
cout << setiosflags(ios::right) << setw(28) << record.contact;
cout << setiosflags(ios::right) << setw(29) << record.email;
cout << setiosflags(ios::right) << setw(100) << record.address << endl; //printing the texts located inside the "AddressBook.txt" in console
}
}
infile.close(); //closing the file
}
else //if file is not open perform this
{
setcolor(12); cout << "File is not open!" << "\n"; rec.viewc2(choice); //calling the function
}
rec.viewc2(choice); //function calling
}
Put your code in code blocks. The <> button.. Also I have no clue what view is, post all relevant code. I also don't know if you are defining the definition and declaring your function Record2 all at the same time or what - but Record2 is not a valid function, where is the function prototype?
For example:
1 2 3 4 5
//Function Prototype as well as Function definition
void Record2()
{
//do stuff
};