Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- void information();
- void book_room();
- struct node
- {
- char room_num[10];
- char name[30];
- char phone_number[15];
- char national_id[20];
- char day[10];
- struct node *next;
- }*head = NULL;
- void empty_room()
- {
- }
- void room_type()
- {
- }
- void book_room()
- {
- FILE *fp, *f;
- int i,a,b,temp, system,num;
- char room[]=".txt";
- struct node *new_node, *current;
- while(1)
- {
- new_node = (struct node*)malloc(sizeof(struct node));
- new_node->next = NULL;
- printf("Enter your choice what you want to do:\n");
- printf("1 for searching empty room\n");
- printf("2 for types of room\n");
- printf("3 room booking\n");
- printf("4 for searching customer details\n");
- printf("5 for food service\n");
- printf("6 for billing system\n");
- printf("7 for check out\n");
- printf("\nEnter : ");
- scanf("%d", &system);
- if (system==3)
- {
- printf("Enter the room no : ");
- scanf(" %[^\n]", new_node->room_num);
- strcat(new_node->room_num, room);
- fp = fopen(new_node->room_num, "w");
- if(fp == NULL){
- perror("This room is already booked");
- return EXIT_FAILURE;
- }
- else{
- printf("Enter your name : ");
- getchar();
- fprintf(fp, gets(new_node->name));
- fprintf(fp, "\n");
- printf("Enter your mobile no : ");
- fprintf(fp, gets(new_node->phone_number));
- fprintf(fp, "\n");
- printf("Enter national id no : ");
- fprintf(fp, gets(new_node->national_id));
- fprintf(fp, "\n");
- printf("How many days you want to stay here : ");
- fprintf(fp, gets(new_node->day));
- fprintf(fp, "\n");
- fclose(fp);
- if(head == NULL){
- head = new_node;
- current = new_node;
- }
- else{
- current->next = new_node;
- current = new_node;
- }
- }
- printf("\nThanks for staying us, Your room is booked successfully :-)\n");
- }
- else if (system==2)
- {
- room_type();
- }
- else if (system==4)
- {
- //customer_details();
- information();
- }
- else if (system==5)
- {
- food_service();
- }
- else if (system==6)
- {
- billing();
- }
- else if (system==6)
- {
- check_out();
- }
- else
- {
- printf("Wrong choice. Please insert a correct value\n\n\n");
- }
- }
- }
- void customer_details()
- {
- }
- void food_service()
- {
- }
- void billing()
- {
- }
- void check_out()
- {
- }
- void information()
- {
- FILE *fp;
- char ch;
- struct node *current;
- current = head;
- while(current != NULL){
- printf("%s\n", current->room_num);
- fp = fopen(current->room_num, "r");
- while(1){
- ch = fgetc(fp);
- if(ch==EOF){
- break;
- }
- putchar(ch);
- }
- current = current->next;
- }
- }
- int main()
- {
- printf(" Our Hotel Management System\n <--------------------------->\n\n\n");
- book_room();
- information();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement