Expand|Select|Wrap|Line Numbers
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include<stdlib.h>
- #include<ctype.h>
- #define N 100
- void addrecord();
- void deleterecord(void);
- void searchrecord(void);
- void modifyrecord(void);
- void viewrecord(void);
- void mainmenu(void);
- struct person{
- char name[N],address[N],email[N];
- long int citino,phone;
- struct dob{
- int dd,mm,yy;
- }d;
- };
- char cho;
- FILE *ptr;
- int main()
- {
- void welcomeMessage();
- mainmenu();
- return 0;
- }
- void welcomeMessage()
- {
- system("COLOR 1F");
- printf("\n\n\n\n\n");
- printf("\n\t\t\t =============================================");
- printf("\n\t\t\t | WELCOME |");
- printf("\n\t\t\t | TO |");
- printf("\n\t\t\t | RECORD |");
- printf("\n\t\t\t | MANAGEMENT |");
- printf("\n\t\t\t | SYSTEM |");
- printf("\n\t\t\t =============================================");
- printf("\n\n\n\t\t\t Enter any key to continue.....");
- getch();
- }
- void mainmenu(void)
- {
- system("COLOR 6F");
- system("cls");
- printf(" ============================================\n");
- printf(" | RECORD MANAGEMENT SYSTEM | \n");
- printf(" ============================================");
- printf("\n\n\n [1] ADD RECORDS--> \n\n [2] VIEW RECORDS--> \n\n [3] SEARCH RECORDS--> \n\n [4] DELETE RECORDS--> \n\n [5] MODIFY RECORDS-->\n\n [6] ABOUT US--> \n\n [7] EXIT--> \n\n\n Enter Your Choice --->");
- int choice;
- scanf("%d",&choice);
- //we have to keep choices here
- if(choice==1)
- addrecord();
- if(choice==3)
- searchrecord();
- if(choice==6)
- {
- system("COLOR 4F");
- system("cls");
- printf("\n\n");
- printf(" A project by:\n\n");
- printf("\n\n");
- printf(" *******************************THANK YOU**************************************\n");
- getch();
- mainmenu();
- }
- if(choice==7){
- system("COLOR 4F");
- system("cls");
- printf("\n\n\n");
- printf(" *******************************THANK YOU**************************************\n");
- }
- }
- //we have to keep choices here
- void addrecord()
- {
- char back1,back2;
- system("cls");
- printf(" ============================================\n");
- printf(" | RECORD MANAGEMENT SYSTEM | \n");
- printf(" ============================================\n\n\n");
- label:
- ptr=fopen("C:\\Users\\Astha\\Downloads\\record.txt","a");
- struct person a;
- fflush(stdin);
- printf("Enter name:");
- gets(a.name);
- fflush(stdin);
- printf("Enter address:");
- gets(a.address);
- fflush(stdin);
- printf("Enter email:");
- gets(a.email);
- fflush(stdin);
- printf("Enter citizenship number:");
- scanf("%ld",&a.citino);
- printf("Enter phone:");
- scanf("%ld",&a.phone);
- printf("Enter date of birth in dd/mm/yy:");
- scanf("%d%c%d%c%d",&a.d.dd,&back1,&a.d.mm,&back2,&a.d.yy);
- fprintf(ptr,"%-30s %-20s %-30s %-20d %-15d %d/%d/%d\n",a.name,a.address,a.email,a.citino,a.phone,a.d.dd,a.d.mm,a.d.yy);
- fclose(ptr);
- fflush(stdin);
- printf("Would you like to enter more records:(y/n)\n");
- printf("Enter choice:");
- fflush(stdin);
- scanf("%c",&cho);
- if(cho=='y'||cho=='Y')
- {
- system("cls");
- printf(" ============================================\n");
- printf(" | RECORD MANAGEMENT SYSTEM | \n");
- printf(" ============================================\n\n\n");
- goto label;
- }
- else if(cho=='n' || cho=='N')
- mainmenu();
- }
- void searchrecord()
- {
- system("cls");
- printf(" ============================================\n");
- printf(" | RECORD MANAGEMENT SYSTEM | \n");
- printf(" ============================================\n\n\n");
- label:
- FILE*f;
- f=fopen("C:\\Users\\Astha\\Downloads\\record.txt","r");
- int flag=0;
- struct person e;
- if(f==NULL)
- {
- printf("\n error in opening\a\a\a\a");
- exit(0);
- }
- char s[100];
- printf(" Enter Name :");
- scanf("%s",s);
- fflush(stdin);
- while(!feof(f) && flag==0)
- {
- if((strcmp(e.name,s))==0) //checks whether a.name is equal to s or not
- {
- flag=1;
- printf(" .........................The Record is available...........................\n\n\n");
- printf(" Name : %s\n\n",e.name);
- printf(" Date OF Birth :%d/%d/%d\n\n",e.d.dd,e.d.mm,e.d.yy);
- printf(" \n Address : %s",e.address);
- printf(" \n Email : %s",e.email);
- printf(" \n Citizenship number : %ld ",e.citino);
- printf(" \n Phone : %ld",e.phone);
- }
- }
- if (flag==0)
- printf("\n aNo Record Found\a");
- printf("\n\n");
- fclose(f);
- fflush(stdin);
- printf("\nWould you like to enter more records:(y/n)\n");
- printf("Enter choice:");
- scanf("%c",&cho);
- if(cho=='y'||cho=='Y')
- {
- system("cls");
- printf(" ============================================\n");
- printf(" | RECORD MANAGEMENT SYSTEM | \n");
- printf(" ============================================\n\n\n");
- goto label;
- }
- else if(cho=='n' || cho=='N')
- mainmenu();
- }