//****************Digital Diary v15***************
//…………….HEADER FILES………………..
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
#include<iostream.h>
#include<process.h>
#include<fstream.h>
#include<ctype.h>
//………………CLASS DEFINITION…………..
class Cperson
{ private:
//private members
int ref; //reference number
char fname[10]; //first name
char lname[10]; //last name
char tel_res_no[15]; //residence number
char tel_off_no[15]; //office number
char tel_mob_no[15]; //mobile number
char tel_fax_no[15]; //fax number
//Office address and pincode
char address_off[80]; //address of the office
char pincode_off[15]; //pincode of the office
//Residence address and pincode
char address_res[80]; //address of the residence
char pincode_res[15]; //pincode of the residence
char email_id[50]; //Email Address
char remarks[90]; //any remarks to be added
public:
Cperson() //constructor
{ tel_res_no[15]; //residence number
tel_off_no[15]; //office number
tel_mob_no[15]; //mobile number
tel_fax_no[15]; //fax number
pincode_off[15]; //pincode(office)
pincode_res[15]; //pincode(residence)
}
char loginid[25];
char password[25];
//public functions
void get_data(); //Function to read details of the contact
void show_data(); //Function that displays details of the contact
void modify(); //Function to modify details of the contact
void search(); //Fuction to search for a contact
void delet(); //Function to delete contact
void login(); //Login function with password & login id
void nofile(); //default starter function
void changepassword(); //function to change the password.
int getrefer() //Accessor function
{ return ref;
}
}aperson; //Object aperson
//end of class Cperson
//********************************************************************
//******************CLASS FUNCTIONS***********************************
//********************************************************************
//FUNCTION TO READ THE DETAILS OF THE CONTACT
void Cperson::get_data(void)
{ char fname1[10]; //first name
char lname1[10]; //last name
char cau[20] = {”!!!! CAUTION !!!!”};
int l=0;
cout<<”\nENTER THE DETAILS OF THE CONTACT \n\n”;
cout<<”\nFIRST NAME:”;
gets(fname1);
for(int i=0;i<20;i++)
fname[i]=0;
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname[i]=toupper(fname1[i]);
}
cout<<”\nLAST NAME:”;
gets(lname1);
for( i=0;i<20;i++)
lname[i]=0;
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname[i]=toupper(lname1[i]);
}
cout<<”\n\n ** QUICK REFERENCE NUMBER **”;
cout<<”\n\n\n\t\t\t”;
for(int j=0;j<=18;j++)
{
cout<<”"<<cau[j];
delay(100);
}
cout<<”\n\nThe reference number that u will enter now cannot be changed later”;
cout<<” and you will have to remember the number if at all you want to delete a contact.”;
cout<<”\n\n To continue, press any key: “;
getch();
delay(500);
cout<<”\n\nENTER QUICK REFERENCE NUMBER: “;
cin>>ref;
cout<<”\n\nRESIDENCE TELEPHONE:”;
gets(tel_res_no);
cout<<”\n\nOFFICE TELEPHONE:”;
gets(tel_off_no);
cout<<”\n\nMOBILE NUMBER:”;
gets(tel_mob_no);
cout<<”\n\nFAX NUMBER:”;
gets(tel_fax_no);
cout<<”\n\nENTER THE ADDRESS AND PINCODE OF THE OFFICE:”;
cout<<”\nADDRESS:”;
gets(address_off);
cout<<”\nPINCODE:”;
gets(pincode_off);
cout<<”\n\nENTER THE ADDRESS AND PINCODE OF THE RESIDENCE:”;
cout<<”\nADDRESS:”;
gets(address_res);
cout<<”\nPINCODE:”;
gets(pincode_res);
cout<<”\nEmail id:”;
gets(email_id);
cout<<”\nREMARKS :”;
gets(remarks);
cout<<”\n\t\t\tSaving….”;
for(int d=0;d<10;d++)
{ cout<<”.”;
delay(150);
}
cout<<”\n\n\n\t\tThis contact has been saved!!!!”;
getch();
}
//end of function getdata
//———————————————————————
//———————————————————————
//FUNCTION TO SHOW THE DETAILS OF THE CONTACT
void Cperson::show_data(void)
{ cout<<”FIRST NAME:”;
puts(fname);
cout<<”LAST NAME:”;
puts(lname);
cout<<”\nQUICK REFERENCE NO. :”<<ref;
cout<<”\nRESIDENCE TELEPHONE:”;
puts(tel_res_no);
cout<<”\nOFFICE TELEPHONE:”;
puts(tel_off_no);
cout<<”\nMOBILE NUMBER:”;
puts(tel_mob_no);
cout<<”\nFAX NUMBER:”;
puts(tel_fax_no);
cout<<”\nTHE ADDRESS AND PINCODE OF THE OFFICE:”;
cout<<”\nADDRESS:”;
puts(address_off);
cout<<”\nPINCODE:”;
puts(pincode_off);
cout<<”\nTHE ADDRESS AND PINCODE OF THE RESIDENCE:”;
cout<<”\nADDRESS:”;
puts(address_res);
cout<<”\nPINCODE:”;
puts(pincode_res);
cout<<”\nEmail id:”;
puts(email_id);
cout<<”\nREMARKS :”;
puts(remarks);
}
//end of function showdata
//———————————————————————-
//———————————————————————-
//FUNCTION TO MODIFY THE DETAILS OF CONTACT
void Cperson::modify(void)
{ int l=0,flag=0;
fstream infile,outfile;
char fname1[20];
char lname1[20];
int ch2;
do
{ int i;
clrscr();
cout<<”\nMODIFY”;
cout<<”\n\n1.RESIDENCIAL ADDRESS”;
cout<<”\n\n2.OFFICIAL ADDRESS”;
cout<<”\n\n3.RESIDENCTIAL TELEPHONE NUMBER”;
cout<<”\n\n4.OFFICIAL TELEPHONE NUMBER”;
cout<<”\n\n5.MOBILE NUMBER”;
cout<<”\n\n6.FAX NO”;
cout<<”\n\n7.EMAIL ID”;
cout<<”\n\n8.REMARKS”;
cout<<”\n\n9.EXIT”;
cout<<”\n\nENTER YOUR CHOICE:”;
cin>>ch2;
//switch….
switch(ch2)
{ case 1://MODIFY RESIDENCIAL ADDRESS
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
if(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW ADDRESS”;
gets(address_res);
cout<<”PINCODE:”;
gets(pincode_res);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 2://MODIFY OFFICIAL ADDRESS
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW ADDRESS”;
gets(address_off);
cout<<”PINCODE:”;
gets(pincode_off);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 3://MODIFY RESIDENCTIAL TELEPHONE NUMBER
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”add_book.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW TELEPHONE NUMBER”;
gets(tel_res_no);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”add_book.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 4://MODIFY OFFICIAL TELEPHONE NUMBER
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW TELEPHONE NUMBER”;
gets(tel_off_no);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 5://MODIFY MOBILE NUMBER
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW TELEPHONE NUMBER”;
gets(tel_mob_no);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 6://MODIFY FAX NUMBER
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW TELEPHONE NUMBER”;
gets(tel_fax_no);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 7://MODIFY THE EMAIL ADDRESS
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE NEW EMAIL ID:”;
gets(email_id);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
case 8://MODIFY THE REMARKS
cout<<”\nENTER FIRST NAME:”;gets(fname1);
l=strlen(fname1);
for(i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in|ios::beg);
outfile.open(”temp.dat”,ios::out);
while(!infile)
{ cout<<”\nERROR”;
exit(0);
}
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(fname,fname1)==0) && (strcmp(lname,lname1)==0))
{ cout<<”\nENTER THE REMARKS:”;
gets(remarks);
outfile.write((char*)&aperson,sizeof(Cperson));
flag=1;
}
else
outfile.write((char*)&aperson,sizeof(Cperson));
}
infile.close();
outfile.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
break;
}
}while(ch2!=9);
}
//end of function modify
//———————————————————————-
//———————————————————————-
//FUNCTION TO SEARCH FOR A CONTACT
void Cperson::search(void)
{ int l;
ifstream infile;
char fname1[20];
char lname1[20];
cout<<”\nENTER FIRST NAME:”;
gets(fname1);
l=strlen(fname1);
for(int i=0;i<l;i++)
{ fname1[i]=toupper(fname1[i]);
}
cout<<”\nENTER LAST NAME:”;
gets(lname1);
l=strlen(lname1);
for(i=0;i<l;i++)
{ lname1[i]=toupper(lname1[i]);
}
infile.open(”diary.dat”,ios::in);
if(!infile)
{ cout<<”\nERROR”;
exit(0);
}
infile.seekg(0,ios::beg);
infile.read((char*)&aperson,sizeof(Cperson));
while (!infile.eof())
{ if((strcmp(fname,fname1)==0) )
{ clrscr();
aperson.show_data();
getch();
}
infile.read((char*)&aperson,sizeof(Cperson));
}
infile.close();
}
//end of function to search
//———————————————————————-
//———————————————————————-
//FUNCTION TO DELETE A CONTACT
void Cperson::delet(void)
{ ifstream fio(”diary.dat”,ios::in);
ofstream fil(”temp.dat”,ios::out);
int refer;
char found=’f',confirm=’n';
cout<<”\n\tEnter reference no. of contact to be deleted :”;
cin>>refer;
while(!fio.eof())
{ fio.read((char *)&aperson,sizeof(aperson));
if(getrefer()==refer)
{ found=’t';
cout<<”\n\tAre you sure you want to delete(y/n) :”;
cin>>confirm;
if(confirm==’n')
fil.write((char *)&aperson,sizeof(aperson));
}
else
fil.write((char *)&aperson,sizeof(aperson));
}
if(found==’f')
{ cout<<”\n\tCONTACT DOES NOT EXIST!!!!”;
exit(0);
getch();
}
fio.close();
fil.close();
remove(”diary.dat”);
rename(”temp.dat”,”diary.dat”);
getch();
}
//***********************FUNCTIONS PROTOTYPES***************************
void display(void); //Function to display all contacts
void add_contact(void); //Function to add a contact
void displaymenu(void); //Function to display menu
void help(); //Help function.
//**********************************************************************
//———————–MAIN ()—————————————-
void main()
{ clrscr();
aperson.login();
}
//**************************************************************************
//———————————————————————–
//FUNCTION TO DISPLAY THE MENU
void displaymenu(void)
{ int ch1;
do
{ clrscr();
cout<<”\n\t\t\tDiGiTAL DiARY v15″;
cout<<”\n\n”;
cout<<”\n\n1. ENTER CONTACT”;
cout<<”\n\n2. SEARCH FOR A CONTACT”;
cout<<”\n\n3. MODiFY”;
cout<<”\n\n4. DiSPLAY DETAiLS OF ALL THE CONTACTS”;
cout<<”\n\n5. DELETE A CONTACT”;
cout<<”\n\n6. CHANGE PASSWORD”;
cout<<”\n\n7. EXiT”;
cout<<”\n\n\n\nENTER YOUR CHOiCE AND PRESS <ENTER>:”;
cin>>ch1;
switch(ch1)
{ case 1: add_contact();
break;
case 2: aperson.search();
break;
case 3: aperson.modify();
break;
case 4: display();
break;
case 5: aperson.delet();
break;
case 6: aperson.changepassword();
break;
case 7: clrscr();
cout<<”\n\n\n\n\n\n\n\n\n\n\n”;
textcolor(GREEN+BLINK);
cout<<”\n\n”;
cputs(” THANK YOU!!”);
cout<<”\n\n********************************************************************************”;
cout<<”\n\n\n\n\t\t\t **Team KAN** “;
cout<<”\n\n\n\t\t\t Made by :-”;
cout<<”\n\n\n\t\t\t Karthik aka Kayjay (member Team KAN)”;
delay(2000);
cout<<”\n\n\n\t\t\tEXITING…”;
for(int z=0;z<15;z++)
{ cout<<”.”;
delay(100);
}
delay(1000);
exit(0);
break;
default:cout<<”THE CHOICE YOU HAVE ENTERED DOES NOT EXIST”;
cout<<”\nPLEASE ENTER THE RIGHT CHOICE : “;
getch();
}
}while (ch1!=6);
}
//**********************************************************************
//FUNCTION TO ADD A CONTACT
void add_contact(void)
{ clrscr();
ofstream f1;
f1.open(”diary.dat”,ios::end|ios::app);
aperson.get_data();
f1.write((char*)&aperson,sizeof(Cperson));
f1.close();
}
//**********************************************************************
//FUNCTION TO DISPLAY DATA
void display(void)
{ Cperson aperson;
ifstream f2;
f2.open(”diary.dat”,ios::beg);
if(!f2)
{ cout<<”ERROR!!!”;
cout<<”\n\n\tEXITING!!!!”;
exit(0);
}
for(int i=0;!f2.eof();i++)
{ clrscr();
f2.read((char*)&aperson,sizeof(Cperson));
aperson.show_data();
delay(1000);
}
f2.close();
getch();
}
//**********************************************************************
//**********************************************************************
//LOGIN FUNCTION
void Cperson::login ()
{
ifstream infile;
infile.open(”details.dat”,ios::in|ios::beg);
while(!infile)
{
nofile();
}
char a,b[25],loginid1[25],lpass[25],ch;
int i;
cout<<”\n\n\n\t\tDiGiTAL DiARY v15\n\n\n\n\n\n”;
cout<<”*******************************************************************************”;
cout<<”\n\nEnter LoginID:”;
gets(loginid1);
cout<<”\n\nEnter password:”;
gets(lpass);
/*
You may activate this part if you dont
the password to be seen while you are entering it.
I am not sure if this will work in all versions of TC / Borland C++.
fflush(stdin);
do
{ ch=getch();
if(isalnum(ch))
{ b[i]=ch;
cout<<”*”;
i++;
}
else
if(ch==’\r’)
b[i]=”;
else if(ch==’\b’)
{ i–;
cout<<”\b\b”;
}
}while(ch!=’\r’);
b[i]=”;
for (int d=0;d<=i;d++) lpass[d]=b[d];
*/
cout<<”\n\n*******************************************************************************”;
cout<<”\n\n\n\n\n\n”;
delay(250);
cout<<”\n\n\t\t PROCESSING…..”;
for(int z=0;z<15;z++)
{ cout<<”.”;
delay(150);
}
int flag=0;
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(loginid,loginid1)==0) && (strcmp(password,lpass)==0))
{
infile.close();
cout<<”\n\n\n\t\t\tWELCOME!!!!”;
delay(750);
displaymenu();
flag=1;
}
else
{
int ch;
cout<<”\n\n\nWrong ID or Password..”;
cout<<”\n\n\nPRESS <1> TO TRY AGAIN OR ANY OTHER NUMBER TO EXIT”;
cout<<”\n\n\t\tSELECT YOUR CHOICE AND PRESS <ENTER>:”;
cin>>ch;
if (ch==1)
{ clrscr();
login();
}
else
{
clrscr();
cout<<”\n\n\n\n\n\n\n\n\n\n\n”;
textcolor(GREEN+BLINK);
cout<<”\n\n”;
cputs(” THANK YOU!!”);
cout<<”\n\n********************************************************************************”;
cout<<”\n\n\n\n\t\t\t **Team KAN** “;
cout<<”\n\n\n\t\t\t Made by :-”;
cout<<”\n\n\n\t\t Karthik a.k.a Kayjay (member Team KAN)”;
delay(500);
cout<<”\n\nEXiTiNG…”;
for(int z=0;z<10;z++)
{ cout<<”.”;
delay(100);
}
delay(1000);
exit(0);
}
}
}
infile.close();
}
//******************************************************************************************************
//******************************************************************************************************
void Cperson::nofile()
{
char chk[25];
ofstream outfile;
outfile.open(”details.dat”,ios::out);
clrscr();
cout<<”ERROR!!!”;
cout<<”\n\n\nReasons….”;
cout<<”\n\n1. Maybe you are running this application for the first time.”;
cout<<”\n\n2. Maybe the changes were not made properly.”;
cout<<”\n\n3. Maybe there was a memory crash.”;
cout<<”\n\n4. Maybe some files would have been misplaced.”;
cout<<”\n\n5. Maybe the program did not shut properly.”;
cout<<”\n\nNo need to panic..a new ID will be created, it is possible that if you are not using this program for the first time, you may still be able to view your saved contacts..”;
cout<<”\n\n\t\tPress any key..”;
getch();
clrscr();
z:
cout<<”\nENTER NEW LOGIN ID (max 20 characters):”;
gets(loginid);
cout<<”\n\nENTER NEW PASSWORD (max 20 characters): “;
gets(password);
cout<<”\n\nRE-TYPE YOUR NEW PASSWORD : “;
gets(chk);
if ( strcmp(chk,password)==0)
{
outfile.write((char*)&aperson,sizeof(Cperson));
outfile.close();
cout<<”\n\nSAVED!!!!!!”;
cout<<”\n\nAs some changes were made, the program will now shut down”;
delay(3000);
exit(0);
}
else
{
clrscr();
cout<<”\nYou entered either an invalid Login ID or the password did not match.\n\n\n”;
goto z;
}
}
//**************************************************************************
//**************************************************************************
void Cperson::changepassword()
{
clrscr();
ifstream infile;
ofstream outfile;
char loginid2[25],chk[25];
cout<<”\n\n\nENTER LOGIN ID (max 20 characters):”;
gets(loginid2);
infile.open(”details.dat”,ios::in|ios::beg);
outfile.open(”tempp.dat”,ios::out);
while(!infile)
{
nofile();
}
int flag=0;
while((!infile.eof())&&(flag==0))
{ infile.read((char*)&aperson,sizeof(Cperson));
if((strcmp(loginid,loginid2)==0))
{ cout<<”\nENTER THE NEW PASSWORD: “;
gets(password);
outfile.write((char*)&aperson,sizeof(Cperson));
infile.close();
outfile.close();
remove(”details.dat”);
rename(”tempp.dat”,”details.dat”);
cout<<”\n\nSAVED!!!!!!”;
cout<<”\n\n\nReturning to the main menu..”;
delay(1000);
displaymenu();
flag=1;
}
else
{
cout<<”\n\nYou have entered an invalid Login ID.”;
delay(2000);
changepassword();
}
}
}
//**************************************************************************
//**************************************************************************
//END..