void directory::modi fication()//???????????
{
clrscr();
cout<< "\n\t @@@@@@ @@@@@ @@@@@ @@@@@@ @@@@@ @ @
@@@@@@ ";
cout<< "\n\t=====@ @ @ @ @ @ @@ @
@ =====";
cout<< "\n\t=====@@@@@ @ @ @ @ @ @ @ @ @ @
@@@ =====";
cout<< "\n\t=====@ @ @ @ @ @ @ @@
@ @ =====";
cout<< "\n\t @@@@@@ @@@@@ @@@@@ @ @@@@@ @ @
@@@@@@ \n\n\n\n";
cout<<"I am inside the modification function before opening of
addressesFiile. ";
getch();
long pn;
int n,i;
ifstream inFile;
ofstream outFile;
inFile.open("ad dressesFile");
if(!inFile)
{
cout<<"\nI am inside the modification function after opening
of addressesFiile. Checking now with if";
getch();
cout<<"\n File not found!";
outFile.close() ;
exit(-1);
}
outFile.open("n ew");
cout<<"\nI am inside the modification function after just creating
new";
getch();
n=test();
if(n==0)
{
cout<<"\nI am inside the modification function. new is
empty";
getch();
cout<<"\n The file is empty. ! ";
getch();
return;
}
cout<<"\nI am inside the modification function before entering the
while loop.";
getch();
int deleteMe = 0;
while(inFile.go od())
{
inFile.read((ch ar*)&obj,sizeof (obj));
outFile.write(( char*)&obj,size of(obj));
cout<<"\nI am inside the modification function inside the while
loop and I have finished round "<<deleteMe +1;
deleteMe = deleteMe + 1;
getch();
}
cout<<"\nI am inside the modification function just outside
the while loop.";
inFile.close();
outFile.close() ;
outFile.open("a ddressesFile",i os::trunc);
inFile.open("ne w");
if(inFile.fail( ))
{
cout<<"\n Sorry! File not found !";
exit(-1);
}
char ch;
cout<<"\n Enter the Land Line Phone Number or the Contact :";
cin>>pn;
ch=cin.get();
cin.get(ch);
for(i=0;i<n;i++ )
{
inFile.read((ch ar*)&obj,sizeof (obj));
char d;
if(pn==landLine Phone)
{
//view1();
cout<<" Name : "<<obj.contactN ame<<"\n";
cout<<" Home Address : "<<obj.homeAddr ess<<"\n";
cout<<" EMAIL ADDRESS : "<<obj.email<<" \n";
cout<<" Cellular Phone Nmber : "<<obj.cellular Phone<<"\n";
cout<<" Land Line Phone Number : "<<obj.landLine Phone<<"\n
\n";
d=check("HOUSE PHONE NUMBER ");
if((d=='y') || (d=='Y'))
{
cout<<"\n Enter the new land line phone number of the
contact, please. :";
cin>>landLinePh one;
ch=cin.get();
cin.get(ch);
}
if(check("OFFIC E PHONE NUMBER ")=='Y')
{
cout<<"\n Enter the new cellular phone number of the
contact, please. :";
cin>>cellularPh one;
ch=cin.get();
cin.get(ch);
}
if(check("Name of the Contact")=='y')
{
cout<<"\n Enter the name of the contact, please. : ";
cin.getline(con tactName,20,'\n ');
}
if(check("HOME ADDRESS")=='y')
{
cout<<"\n Enter the new Home Address of the contact,
please. :";
cin.getline(hom eAddress,50,'\n ');
}
if(check("EMAIL ADDRESS:")=='y' )
{
cout<<"\n Enter the new E-mail Address of the contact,
please. :";
cin.getline(ema il,25,'\n');
}
}//the outer if ends here.
outFile.write(( char*)&obj,size of(obj));
}
outFile.close() ;
inFile.close();
}