Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX 100
- typedef struct {
- char Title[30]; // title of movie
- char UCPNumber[12]; // ????
- int quantity; //quantity of tickets
- double price; //price of the movie
- }MOVIES; //name of the struct
- //void GetStuff(MOVIES* movie);
- void PrintMenu(void); //print the menu and send to functions
- void GetStuff(MOVIES* movie);
- void DisplayMoviesInfo(MOVIES* movie);
- void main()
- {
- char Title[30]; // title of movie
- char UCPNumber[12]; // ????
- int quantity = 0; //quantity of tickets
- double price = 0; //price of the movie
- MOVIES movie[MAX] = //keep info of movie
- {
- { Title, UCPNumber, quantity, price },
- };
- PrintMenu(); //print and get the main menu info
- printf("\t\tpress enter to leave"); //exits the program
- getchar(); // get enter key from user
- }
- void GetStuff(MOVIES* movie) //get info & (check if it was already there) <- not done yet
- {
- char ch[500], movietitle[20];
- FILE* fpw;
- fpw = fopen("D:\\prgfiles\\labproject.txt", "ab");
- getchar();
- printf("\ngive me the name for the movie: ");
- gets(movie->Title);
- printf("\ngive me the UCP/SKU Number for the movie: %s : ", movie->Title);
- scanf("%s", &movie->UCPNumber);
- printf("\ngive me the quantity for the movie: %s : ", movie->Title);
- scanf("%d", &movie->quantity);
- printf("\ngive me the price for the movie: %s : ", movie->Title);
- scanf("%lf", &movie->price);
- fwrite(movie, sizeof(MOVIES), 1, fpw);
- if (fpw == NULL)
- {
- printf("Error");
- exit(1);
- }
- gets(ch);
- fputs(ch, fpw);
- fclose(fpw);
- }
- void DisplayMoviesInfo(MOVIES* movie)
- {
- }
- void PrintMenu(void)
- {
- char choose;
- printf("\n\n\t\tChoose a action.\n\n");
- printf("\t(A)dd a New Movie\n");
- printf("\t(C)hange a Movie's Information\n");
- printf("\t(D)elete a Movie\n");
- printf("\t(L)ist All Movies \n");
- printf("\t(Q)uit \n");
- printf("\ttype the letter required to do such action:");
- scanf("%c", &choose);
- switch (choose)
- {
- case'A':
- case 'a':
- {
- printf("\n\tYou chose Add a new movie\n");
- char Title[30]; // title of movie
- char UCPNumber[12]; // ????
- int quantity = 0; //quantity of tickets
- double price = 0; //price of the movie
- MOVIES movie[MAX] = //keep info of movie
- {
- { Title, UCPNumber, quantity, price },
- };
- GetStuff(&movie);
- getchar();
- PrintMenu();
- }
- break;
- case'C':
- case'c':
- {
- printf("\n\tYou chose Change a Movie's Information\n");
- }
- break;
- case'D':
- case'd':
- {
- printf("\n\tYou chose Delete a Movie\n");
- }
- break;
- case'L':
- case'l':
- {
- char Title[30]; // title of movie
- char UCPNumber[12]; // ????
- int quantity = 0; //quantity of tickets
- double price = 0; //price of the movie
- MOVIES movie[MAX] = //keep info of movie
- {
- { Title, UCPNumber, quantity, price },
- };
- DisplayMoviesInfo(movie);
- }
- break;
- case'Q':
- case'q':
- {
- printf("\n\tYou chose To QUIT\n");
- }
- break;
- default:
- {
- printf("\nyou chose a wrong character\n");
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement