//Names inside the text files are: Darwin, Bea, Hans, Denzell
//I want to print them in alphabetically order so the print out in console will
//be like this: Bea, Darwin, Denzell, Hans
void Record2::view(int RunnningCount) //VIEWING THE RECORD'S LIST
{
system("cls"); system("color 1a");
ifstream infile("AddressBook.txt"); //opening the file for reading only
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
{
cout << setiosflags(ios::left) << setw(1) << ++RunnningCount;
cout << setiosflags(ios::right) << setw(31) << record.fullname;
cout << setiosflags(ios::right) << setw(27) << record.contact;
cout << setiosflags(ios::right) << setw(28) << record.email;
cout << setiosflags(ios::right) << setw(99) << 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
{
cout << "File is not open!" << "\n"; rec.viewc2(choice); //calling the function
}
rec.viewc2(choice); //function calling
}