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 NewMovie(MOVIES* dvd, int size); // will hold tempmovie if it return a new UCP
- void TempMovie(MOVIES* dvd, int size);
- int FindMovie(MOVIES* dvd, int size, char UCPNumber[12]);
- int main(void)
- {
- char Title[30]; // title of movie
- char UCPNumber[12]; // ????
- int quantity; //quantity of tickets
- double price; //price of the movie
- int size = 0, idx = 0, quit = 0;
- char choose;
- choose = 0;
- MOVIES dvd[MAX];
- do{
- 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':
- {
- TempMovie(&dvd, size);
- size++;
- }
- 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':
- {
- }
- break;
- case'Q':
- case'q':
- {
- printf("\n\tYou chose To QUIT\n");
- quit = 1;
- }
- break;
- default:
- {
- printf("\nyou chose a wrong character\n");
- }
- break;
- }
- system("cls");
- choose = 0;
- //check if UCP is equal
- FindMovie(dvd, size, UCPNumber);
- } while (quit < 1);
- }
- void TempMovie(MOVIES* dvd)
- {
- getchar();
- printf("\ngive me the Title for the new movie: ");
- gets(&dvd->Title);
- printf("\ngive me the UCP/SKU for the movie %s : ", dvd->Title);
- gets(&dvd->UCPNumber);
- printf("\ngive me the quantity for the movie %s : ", dvd->Title);
- scanf("%d", &dvd->quantity);
- printf("\ngive me the price for the movie %s : ", dvd->Title);
- scanf("%d", &dvd->price);
- }
- int FindMovie(MOVIES * dvd, int size, char UCPNumber[12]) //wrong
- //int FindMovie(dvdlist* find, int j, char code[12])
- {
- int result;
- int i, new = 0, old =0;
- for (int i = 0; i <= size; i++)
- {
- result = strcmp((dvd + i)->whathere, UCPNumber);
- if (result == 0)
- {
- new = 0;
- return new;
- }
- else
- {
- old = -1;
- return old;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement