Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct show
- {
- char name[255];
- char date[255];
- int total_ticket;
- int ticket_available;
- int price;
- };
- void addShow(struct show *listings, int *numShows)
- {
- char name[255];
- char date[255];
- int total_ticket;
- int ticket_available;
- int price;
- // scanf("%s", &b);
- char a;
- printf("------------------------------------------------\n");
- printf("Name of the show : ");
- getchar(); // consume new line
- gets(listings[*numShows].name);
- printf("When will it go live : ");
- gets(listings[*numShows].date);
- printf("Total tickets: ");
- scanf("%d", &listings[*numShows].total_ticket);
- printf("Tickets currently available: ");
- scanf("%d", &listings[*numShows].ticket_available);
- printf("Ticket price: ");
- scanf("%d", &listings[*numShows].price);
- // printf("------------------------------------------------\n");
- // printf("Name of the show: %s\n", listings[*numShows].name);
- // printf("Shows at: %s\n", listings[*numShows].date);
- // printf("Total tickets: %d\n", listings[*numShows].total_ticket);
- // printf("Tickets currently available: %d\n", listings[*numShows].ticket_available);
- // printf("Ticket price: %d\n", listings[*numShows].price);
- *numShows += 1;
- }
- void displayShows(struct show *listings, int numShows)
- {
- printf("------------------------------------------------\n");
- for (int i = 0; i < numShows; i++)
- {
- printf("Show no %d\n", i + 1);
- printf("Name of the show: %s\n", listings[i].name);
- printf("Shows at: %s\n", listings[i].date);
- printf("Total tickets: %d\n", listings[i].total_ticket);
- printf("Tickets currently available: %d\n", listings[i].ticket_available);
- printf("Ticket price: %d\n", listings[i].price);
- printf("\n");
- }
- }
- void bookTicket(struct show *listing, int numShows, char *showName)
- {
- for (int i = 0; i < numShows; i++)
- {
- int len = 0;
- while (showName[len] != '\0')
- {
- len++;
- }
- printf("%d", len);
- }
- };
- int main()
- {
- struct show showsArray[500];
- int numShows = 0;
- int menu = 1;
- while (menu != 6)
- {
- printf("1. Add a show\n");
- printf("2. Book a ticket\n");
- printf("3. List out the shows\n");
- printf("4. Save to file\n");
- printf("5. Load from file\n");
- printf("6. Exit\n");
- scanf("%d", &menu);
- if (menu == 1)
- {
- addShow(showsArray, &numShows);
- }
- else if (menu == 3)
- {
- displayShows(showsArray, numShows);
- }
- printf("------------------------------------------------\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement