Hello Everyone I created an address book by using arrays !... Here I got a problem with sorting arrays of type String .... When I want to Sort a contacts It will just Sort the first names Without moving Second name and phone numb..... etc .. I have no clear Idea about Moving whole line to sort in the address book ! ... I mean moving [first name, surname, phone number, Email] at the same time to the next line !... here is my Code!
void sortRecords() {
ofstream Cfile;
Cfile.open("addressbook.txt", ios::in);
string temp;
for (int i=0; i<line()-1; ++i)
{
for (int j=0; j<line()-1-i; j++)
{
while (first_name[j]>first_name[j+1])
{
temp= first_name[j+1];
first_name[j+1]=first_name[j];
first_name[j]=temp;
}
}
}
for (int p=0; p<line();p++)
{
Cfile<<first_name[p]<<setw(10)<<sur_name[p]<<setw(10)<<phone_number[p]<<setw(10)<<email[p]<<endl;
}
Cfile.close();
}