⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digiv15.cpp

📁 强大的电子通讯录
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ==============  Program Description  ==============   */
/*   Program name : DiGiTAL DiARY v15                    */
/*   Programmer   : Karthik Jairam a.k.a Kayjay          */
/*   Programming unit : Team KAN                         */
/*                                                       */
/*   This program is an improved version of an already   */
/*   existing program in this website. Some functions    */
/*   were not working which have been corrected and some */
/*   funtions are added to make the program more user    */
/*   friendly. This program before had password written  */
/*   in the code itself, but i have used a file to store */
/*   the password which can be later be changed too.     */
/*                                                       */
/* PLEASE NOTE : If you are making changes, then dont    */
/* change the order of the functions, but if you still   */
/* want to, then declare all the functions in the class  */
/* ====================================================  */


//****************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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -