[c] project
Viewer
- #include <stdio.h>
- struct Patient{
- char name[25];
- int phone_no, age;
- }p[100];
- int serial = 0;
- int main()
- {
- int menu;
- char pass[10];
- char password[10] = "admin";
- for(int i=1; i>=1; i++){
- my_menu();
- printf("\nEnter menu option : ");
- scanf("%d", &menu);
- if(menu==1){
- enter_info();
- }
- else if(menu==2){
- load_info();
- }
- else if(menu==3){
- printf("Enter password : ");
- getchar();
- gets(pass);
- if(strcmp(pass, password)==0){
- load_all_info();
- }
- else printf("Incorrect password!");
- }
- else if(menu==4){
- printf("\nThanks for using me!!");
- break;
- }
- else printf("wrong keyword!");
- }
- }
- void my_menu(void){
- printf("\t\t--------------------------------------\n");
- printf("\t\t\tWelcome to main menu!\n");
- printf("\t\t--------------------------------------\n\n");
- printf("1. Enter patient's information for visiting doctor\n");
- printf("2. See your patient's visiting time\n");
- printf("3. See patient's information(only admins can check it, PASSWORD PROTECTED!!)\n");
- printf("4. exit\n\n");
- return 0;
- }
- void enter_info(void){
- printf("\n\nEnter patient's name : ");
- getchar();
- gets(p[serial].name);
- printf("Enter age : ");
- getchar();
- scanf("%d", &p[serial].age);
- printf("Enter phone no : ");
- getchar();
- scanf("%d", &p[serial].phone_no);
- getchar();
- printf("Your serial no : %d [PLEASE, MEMORIZE IT CAREFULLY]\n\n", serial+1);
- serial = serial + 1;
- return 0;
- }
- void load_info(void){
- int s;
- int initial_hour = 5, visiting_hour, visiting_minute = 0;
- printf("\nEnter your serial no : ");
- scanf("%d", &s);
- visiting_hour = initial_hour + (s*15)/60;
- visiting_minute = ((s-1)*15)%60;
- printf("\nPatient's name : %s", p[s-1].name);
- printf("\nPatient's age : %d", p[s-1].age);
- printf("\nPatient's phone no : %d", p[s-1].phone_no);
- printf("\nyour visiting time : %d.%d pm\n\n\n", visiting_hour, visiting_minute);
- return 0;
- }
- void load_all_info(void){
- for(int i=0; i<serial; i++){
- printf("\nInformation of patient %d", i+1);
- printf("\nPatient's name : %s", p[i].name);
- printf("\nPatient's age : %d", p[i].age);
- printf("\nPatient's phone no : %d\n\n", p[i].phone_no);
- }
- return 0;
- }
Editor
You can edit this paste and save as new: