Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<conio.h>
- #include<stdlib.h> //for using styme("CLS")
- #define ENTER 13
- #define BKSP 8
- //subfunction diclaration
- void login();
- void menu();
- struct data
- {
- int phone,batch;
- char name [100];
- char email[100];
- char blood_group[10];
- } entry;
- //char query[20],name[20];
- // FILE *fp,*ft;
- // int i,n,l,found;
- int main()
- {
- login(); // call login function
- return 0;
- }
- void login()
- {
- int i;
- char password[100],ch;
- char username[100];
- printf("\n\n\t\t*************************************************\n\t\t*\t\t\t\t\t\t*\n\t\t*\tENTER YOUR USERNAME AND PASSWORD\t*\n\t\t*\t\t\t\t\t\t*\n\t\t*************************************************\n");
- printf("\n\t\t\tUSERNAME:");
- scanf("%s",&username);
- printf("\n\t\t\tPASSWORD:");
- for(i=0; i<100; i++) //loop for password input
- {
- ch = getch(); //getch don't showing input from user
- if(ch==ENTER)
- {
- break;
- }
- else
- {
- password[i] = ch;
- ch = '*' ;
- printf("%c",ch);
- }
- }
- password[i] = '\0'; //in string last character is a null character
- if(strcmp(username,"abc")==0) // strcmp for compearision
- {
- if(strcmp(password,"123")==0)
- {
- getch(); // getch is used to hold the window
- system("CLS");
- printf("\n\n\t\tSUCCESSFULLY LOG IN......");
- printf("\n\n\t\tPress Any Key To Countinue..... ");
- getch();
- system("CLS");
- menu(); // call menu function
- }
- else
- {
- printf("\n\n\t\tPlease Enter Correct Password.....");
- printf("\n\n\t\tPress Any Key To Countinue..... ");
- getch();
- system("CLS"); //system("CLS") using for clear screen
- login(); // call login function
- }
- }
- else
- {
- printf("\n\n\t\tPlease Enter Correct Username.....");
- printf("\n\n\t\tPress Any Key To Countinue..... ");
- getch();
- system("CLS");
- login(); // call login function
- }
- }
- void menu()
- {
- int choice,quit,c;
- FILE *fp,*ft;
- int i,n,l,found;
- printf("\n\n\t\t ======WELCOME TO BLOOD GROUP MANAGEMENT======\n");
- printf("\n\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*\n\t\t\t*\t Main Menu \t*\n\t\t\t*\t\t\t\t*\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*");
- printf("\n\t\t\t*\t [1]Data Entry\t\t*\n");
- printf("\t\t\t*\t [2]All List\t\t*\n");
- printf("\t\t\t*\t [3]Search\t\t*\n");
- printf("\t\t\t*\t [4]Delete\t\t*\n");
- printf("\t\t\t*\t [5]About Us\t\t*\n");
- printf("\t\t\t*\t [6]Exit\t\t*\n\t\t\t*\t\t\t\t*\n");
- printf("\t\t\t*********************************\n\n");
- printf("\t\t\t\tChoise Any Number: ");
- scanf("%d",&choice);
- switch(choice)
- {
- case 6:
- system("CLS");
- printf("\n\n\n\t\t\t*********************************\n\t\t\t*\t Are you sure?\t*\n\t\t\t*********************************\n\t\t\t*\t[1]YES *\t[2]NO *\n\t\t\t*********************************");
- printf("\n\n\t\t\tChoise Any Number: ");
- scanf("%d",&quit);
- if(quit==1)
- {
- system("CLS");
- printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
- break;
- }
- else if(quit==2)
- {
- system("CLS");
- menu(); // call menu function
- }
- else
- {
- printf("\n\n\t\t\tInvalid....\n\n ");
- getch();
- system("CLS");
- menu(); //if invalid go to menu
- }
- break;
- case 2:
- system("CLS");
- printf("\n\n\t\t\tAll lists:\n\n");
- for(i=0;i<100;i++)
- {
- printf("\t\t\t%d.Empty\n",i);
- }
- printf("\n\n\t\t\tPress 1 to go back.");
- scanf("%d",&c);
- if(c==1)
- {
- system("CLS");
- menu();
- }
- case 1:
- system("CLS");
- fp=fopen("bloodgroup.txt","a"); //open a text file name bloodgroup.txt
- printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
- while(1)
- {
- fflush(stdin); //fflush(stdin) using for clear buffer memory
- printf("\n\t\t(to exit enter a blank space in name option)");
- printf("\n\n\t\t\tName:");
- gets(entry.name);
- if( strcmp(entry.name," ")==0)
- {
- break;
- }
- fflush(stdin);
- printf("\t\t\tBlood Group:");
- gets(entry.blood_group);
- fflush(stdin);
- printf("\t\t\tBatch:");
- scanf("%d",&entry.batch);
- fflush(stdin);
- printf("\t\t\tPhone:");
- scanf("[%d",&entry.phone);
- fflush(stdin);
- printf("\t\t\tEmail:");
- gets(entry.email);
- fflush(stdin);
- fwrite(&entry,sizeof(entry),1,fp); //fwrite for written all entry in file
- system("CLS");
- printf("\n\n\t\t\t ENTRY YOUR USEFUL DATA\n\t===========================================================");
- }
- printf("\n\n\n\t\t\t(Press [1]exit or [2]menu)");
- printf("\n\n\t\t\tChoise Any Number: ");
- scanf("%d",&quit);
- if(quit==1)
- {
- system("CLS");
- printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
- break;
- }
- else if(quit==2)
- {
- system("CLS");
- menu(); // call menu function
- }
- else
- {
- printf("\n\n\t\t\tPlease Enter Valid Option....\n\n ");
- getch();
- system("CLS");
- menu();
- fclose(fp); //closing file
- break;
- case 5:
- system("CLS");
- printf("\n\n\t\tINFORMATION ABOUT GROUP 404 NOT FOUND\n\t===========================================================");
- printf("\n\t\tName:Md.Mahedi Hasan\n\t\tID:181-15-10900\n\t\tSECTION:D\n");
- printf("\n\t\tName:Sajib Ahmed\n\t\tID:181-15-10874\n\t\tSECTION:D\n");
- printf("\n\t\tName:Mohd.Mehedi Hasan Joy\n\t\tID:181-15-10628\n\t\tSECTION:D\n");
- printf("\n\t\tName:Akkhar Ulok\n\t\tID:181-15-11207\n\t\tSECTION:D");
- printf("\n\n\t\t\tThis is an c project\n\t===========================================================");
- printf("\n\t\t\tPress any key to continue....");
- getch();
- system("CLS");
- menu();
- break;
- default:
- printf("\n\t\t\tPlease Enter Valid Option....");
- printf("\n\t\t\tPress any key to continue....");
- getch();
- system("CLS");
- menu();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement