Run this code in turbo c++ compiler because it will run without errors in that compiler and DON'T COPY THIS PROGRAM FOR COMMERCIAL USE.Copy only if you know c programming very well if you don't know c programming then learn it from this website.
Program:
/*Program name: Contacts management System*/
/*Creater: Aadarsh sojitra OR owner of www.errorless-c.in*/
/*----------Including Header Files----------*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
/*---------------------STRUCTURE--------------------*/
struct c_inf
{
char c_id[10];
char c_name[600];
char c_email[200];
char c_phoneM[30];
char c_phoneO[30];
char c_phoneH[30];
char c_category[300];
char c_Address[2000];
}
/*---------------------Declaring Main---------------------*/
main()
{
FILE *dat;
struct c_inf b;
int cho,choin;
char inf,yn,ryn;
struct date d;
clrscr();
getdate(&d);
while(1) /*--------------------Infinity Loop-------------------*/
{
/*----------------Starting Information----------------*/
printf("\n ============================Contacts management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\n\t\t\t[1] : Enter New contact");
printf("\n\t\t\t[2] : View contact info.");
printf("\n\t\t\t[3] : Edit contact info.");
printf("\n\t\t\t[4] : Remove contact");
printf("\n\t\t\t[5] : Exit");
printf("\n\n\t\t\tEnter Here ---> ");
scanf("%d",&cho);
/*--------------------------------------------*/
/*--------------Switch Choice Entered By user-------------*/
switch(cho)
{
/*--------------------------Case 1------------------------*/
case 1:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Add Window=====");
printf("\n\n\tEnter contact id: ");
fflush(stdin);
gets(b.c_id);
if(access(b.c_id)!=-1)
{
printf("\n\tcontact already exist!!!");
}
else
{
dat=fopen(b.c_id,"w");
printf("\n\tEnter contact Name: ");
fflush(stdin);
gets(b.c_name);
printf("\n\tEnter contact's email name: ");
fflush(stdin);
gets(b.c_email);
printf("\n\tEnter contact's Phone no. (Home): ");
fflush(stdin);
gets(b.c_phoneH);
printf("\n\tEnter contact's Phone no. (Office): ");
fflush(stdin);
gets(b.c_phoneO);
printf("\n\tEnter contact's Phone no. (Mobile): ");
fflush(stdin);
gets(b.c_phoneM);
printf("\n\tEnter Contact Category: ");
fflush(stdin);
gets(b.c_category);
printf("\n\tEnter Contact Address: ");
fflush(stdin);
gets(b.c_Address);
fprintf(dat,"contact id: %s",b.c_id);
fprintf(dat,"\ncontact Name: %s",b.c_name);
fprintf(dat,"\ncontact email: %s",b.c_email);
fprintf(dat,"\ncontact Contact's phone no. (home): %s",b.c_phoneH);
fprintf(dat,"\ncontact Contact's phone no. (Office): %s",b.c_phoneO);
fprintf(dat,"\ncontact Contact's phone no. (Mobile): %s",b.c_phoneM);
fprintf(dat,"\ncontact Category: %s",b.c_category);
fprintf(dat,"\nccontact Address: %s",b.c_Address);
printf("\n\n\tContact Added Successfully!");
fclose(dat);
}
printf("\n\n\tWant to add more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*-------------------End of Case 1-----------------------*/
/*----------------------Case 2---------------------------*/
case 2:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====View Window=====");
printf("\n\n\tEnter contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tcontact Does not Exist");
printf("\n\n\tPress any key to go to main menu..........");
getch();
clrscr();
break;
}
inf=fgetc(dat);
printf("\n\n--------------------------------------------------------------------------------");
while(inf!=EOF)
{
printf("%c",inf);
inf=fgetc(dat);
}
printf("\n--------------------------------------------------------------------------------");
fclose(dat);
printf("\n\n\tWant to View more Contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*-------------------End of case 2-----------------------*/
/*-----------------------Case 3--------------------------*/
case 3:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Edit Window=====");
printf("\n\n\tEnter Contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tc Does not Exist");
printf("\n\n\tPress any key to go to main menu..........");
getch();
clrscr();
break;
}
inf=fgetc(dat);
printf("\n\n--------------------------------------------------------------------------------");
printf("CURRENT DATA: \n\n");
while(inf!=EOF)
{
printf("%c",inf);
inf=fgetc(dat);
}
printf("\n--------------------------------------------------------------------------------");
fclose(dat);
dat=fopen(b.c_id,"w+");
printf("\n\tEnter New contact Name: ");
fflush(stdin);
gets(b.c_name);
printf("\tEnter New contact's email name: ");
fflush(stdin);
gets(b.c_email);
printf("\tEnter New contact's Phone no. (Home): ");
fflush(stdin);
gets(b.c_phoneH);
printf("\tEnter New contact's Phone no. (Office): ");
fflush(stdin);
gets(b.c_phoneO);
printf("\tEnter New contact's Phone no. (Mobile): ");
fflush(stdin);
gets(b.c_phoneM);
printf("\tEnter New contact Category: ");
fflush(stdin);
gets(b.c_category);
printf("\tEnter contact Address: ");
fflush(stdin);
gets(b.c_Address);
fprintf(dat,"c id: %s",b.c_id);
fprintf(dat,"\ncontact Name: %s",b.c_name);
fprintf(dat,"\ncontact email: %s",b.c_email);
fprintf(dat,"\ncontact Contact's phone no. (home): %s",b.c_phoneH);
fprintf(dat,"\ncontact Contact's phone no. (Office): %s",b.c_phoneO);
fprintf(dat,"\ncontact Contact's phone no. (Mobile): %s",b.c_phoneM);
fprintf(dat,"\ncontact Category: %s",b.c_category);
fprintf(dat,"\ncontact Address: %s",b.c_Address);
printf("\n\tContact Edited Successfully!");
fclose(dat);
printf("\n\n\tWant to Edit more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*--------------------End of case 3----------------------*/
/*------------------------Case 4-------------------------*/
case 4:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Remove Window=====");
printf("\n\n\tEnter contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tc Does not Exist");
}
else
{
remove(b.c_id);
printf("\n\tcontacts Removed Successfully!");
}
printf("\n\n\tWant to Remove more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*--------------------End of Case 4----------------------*/
/*------------------------Case 5-------------------------*/
case 5: clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\n Thanks for using Software\n\n A software by Sojitra Aadarsh");
printf("\n\n Contact No.: 9662072282");
printf("\n\n Location: Gujarat in India");
printf("\n\n Program will terminate in 3 seconds");
delay(3000);
exit(0);
/*--------------------End of Case 5----------------------*/
/*---------------------Default Case----------------------*/
default:
printf("\n\n\tSYSTEM ERROR PLEASE RESTART SOFTWARE");
printf("\n\t\tProgram will terminate in 3 seconds");
delay(3000);
exit(0);
/*----------------------End of Default Case----------------------*/
}
}
getch();
}
Program:
/*Program name: Contacts management System*/
/*Creater: Aadarsh sojitra OR owner of www.errorless-c.in*/
/*----------Including Header Files----------*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
/*---------------------STRUCTURE--------------------*/
struct c_inf
{
char c_id[10];
char c_name[600];
char c_email[200];
char c_phoneM[30];
char c_phoneO[30];
char c_phoneH[30];
char c_category[300];
char c_Address[2000];
}
/*---------------------Declaring Main---------------------*/
main()
{
FILE *dat;
struct c_inf b;
int cho,choin;
char inf,yn,ryn;
struct date d;
clrscr();
getdate(&d);
while(1) /*--------------------Infinity Loop-------------------*/
{
/*----------------Starting Information----------------*/
printf("\n ============================Contacts management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\n\t\t\t[1] : Enter New contact");
printf("\n\t\t\t[2] : View contact info.");
printf("\n\t\t\t[3] : Edit contact info.");
printf("\n\t\t\t[4] : Remove contact");
printf("\n\t\t\t[5] : Exit");
printf("\n\n\t\t\tEnter Here ---> ");
scanf("%d",&cho);
/*--------------------------------------------*/
/*--------------Switch Choice Entered By user-------------*/
switch(cho)
{
/*--------------------------Case 1------------------------*/
case 1:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Add Window=====");
printf("\n\n\tEnter contact id: ");
fflush(stdin);
gets(b.c_id);
if(access(b.c_id)!=-1)
{
printf("\n\tcontact already exist!!!");
}
else
{
dat=fopen(b.c_id,"w");
printf("\n\tEnter contact Name: ");
fflush(stdin);
gets(b.c_name);
printf("\n\tEnter contact's email name: ");
fflush(stdin);
gets(b.c_email);
printf("\n\tEnter contact's Phone no. (Home): ");
fflush(stdin);
gets(b.c_phoneH);
printf("\n\tEnter contact's Phone no. (Office): ");
fflush(stdin);
gets(b.c_phoneO);
printf("\n\tEnter contact's Phone no. (Mobile): ");
fflush(stdin);
gets(b.c_phoneM);
printf("\n\tEnter Contact Category: ");
fflush(stdin);
gets(b.c_category);
printf("\n\tEnter Contact Address: ");
fflush(stdin);
gets(b.c_Address);
fprintf(dat,"contact id: %s",b.c_id);
fprintf(dat,"\ncontact Name: %s",b.c_name);
fprintf(dat,"\ncontact email: %s",b.c_email);
fprintf(dat,"\ncontact Contact's phone no. (home): %s",b.c_phoneH);
fprintf(dat,"\ncontact Contact's phone no. (Office): %s",b.c_phoneO);
fprintf(dat,"\ncontact Contact's phone no. (Mobile): %s",b.c_phoneM);
fprintf(dat,"\ncontact Category: %s",b.c_category);
fprintf(dat,"\nccontact Address: %s",b.c_Address);
printf("\n\n\tContact Added Successfully!");
fclose(dat);
}
printf("\n\n\tWant to add more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*-------------------End of Case 1-----------------------*/
/*----------------------Case 2---------------------------*/
case 2:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====View Window=====");
printf("\n\n\tEnter contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tcontact Does not Exist");
printf("\n\n\tPress any key to go to main menu..........");
getch();
clrscr();
break;
}
inf=fgetc(dat);
printf("\n\n--------------------------------------------------------------------------------");
while(inf!=EOF)
{
printf("%c",inf);
inf=fgetc(dat);
}
printf("\n--------------------------------------------------------------------------------");
fclose(dat);
printf("\n\n\tWant to View more Contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*-------------------End of case 2-----------------------*/
/*-----------------------Case 3--------------------------*/
case 3:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Edit Window=====");
printf("\n\n\tEnter Contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tc Does not Exist");
printf("\n\n\tPress any key to go to main menu..........");
getch();
clrscr();
break;
}
inf=fgetc(dat);
printf("\n\n--------------------------------------------------------------------------------");
printf("CURRENT DATA: \n\n");
while(inf!=EOF)
{
printf("%c",inf);
inf=fgetc(dat);
}
printf("\n--------------------------------------------------------------------------------");
fclose(dat);
dat=fopen(b.c_id,"w+");
printf("\n\tEnter New contact Name: ");
fflush(stdin);
gets(b.c_name);
printf("\tEnter New contact's email name: ");
fflush(stdin);
gets(b.c_email);
printf("\tEnter New contact's Phone no. (Home): ");
fflush(stdin);
gets(b.c_phoneH);
printf("\tEnter New contact's Phone no. (Office): ");
fflush(stdin);
gets(b.c_phoneO);
printf("\tEnter New contact's Phone no. (Mobile): ");
fflush(stdin);
gets(b.c_phoneM);
printf("\tEnter New contact Category: ");
fflush(stdin);
gets(b.c_category);
printf("\tEnter contact Address: ");
fflush(stdin);
gets(b.c_Address);
fprintf(dat,"c id: %s",b.c_id);
fprintf(dat,"\ncontact Name: %s",b.c_name);
fprintf(dat,"\ncontact email: %s",b.c_email);
fprintf(dat,"\ncontact Contact's phone no. (home): %s",b.c_phoneH);
fprintf(dat,"\ncontact Contact's phone no. (Office): %s",b.c_phoneO);
fprintf(dat,"\ncontact Contact's phone no. (Mobile): %s",b.c_phoneM);
fprintf(dat,"\ncontact Category: %s",b.c_category);
fprintf(dat,"\ncontact Address: %s",b.c_Address);
printf("\n\tContact Edited Successfully!");
fclose(dat);
printf("\n\n\tWant to Edit more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*--------------------End of case 3----------------------*/
/*------------------------Case 4-------------------------*/
case 4:
while(1)
{
clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\t\t\t =====Remove Window=====");
printf("\n\n\tEnter contact id : ");
fflush(stdin);
gets(b.c_id);
dat=fopen(b.c_id,"r");
if(dat==NULL)
{
printf("\n\tc Does not Exist");
}
else
{
remove(b.c_id);
printf("\n\tcontacts Removed Successfully!");
}
printf("\n\n\tWant to Remove more contacts (Y/N): ");
scanf("%c",&yn);
if(yn=='N')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
else if(yn=='n')
{
printf("\n\tPress any key to quit to main menu......");
getch();
break;
}
}
clrscr();
break;
/*--------------------End of Case 4----------------------*/
/*------------------------Case 5-------------------------*/
case 5: clrscr();
printf("\n ============================Contacts Management==============================");
printf(" Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
printf("\n\n Thanks for using Software\n\n A software by Sojitra Aadarsh");
printf("\n\n Contact No.: 9662072282");
printf("\n\n Location: Gujarat in India");
printf("\n\n Program will terminate in 3 seconds");
delay(3000);
exit(0);
/*--------------------End of Case 5----------------------*/
/*---------------------Default Case----------------------*/
default:
printf("\n\n\tSYSTEM ERROR PLEASE RESTART SOFTWARE");
printf("\n\t\tProgram will terminate in 3 seconds");
delay(3000);
exit(0);
/*----------------------End of Default Case----------------------*/
}
}
getch();
}