Advertisement
octavio123

funciuonando

Apr 7th, 2020
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.51 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define MAX 100
  5. typedef struct {
  6.     char Title[30]; // title of movie
  7.     char UCPNumber[12]; // ????
  8.     int quantity; //quantity of tickets
  9.     double price; //price of the movie
  10. }MOVIES; //name of the struct
  11.  
  12.  
  13.  
  14. //void GetStuff(MOVIES* movie);
  15. void PrintMenu(void); //print the menu and send to functions
  16. void GetStuff(MOVIES* movie);
  17. void DisplayMoviesInfo(MOVIES* movie);
  18.  
  19.  
  20.  
  21.  
  22. void main()
  23. {
  24.     char Title[30]; // title of movie
  25.     char UCPNumber[12]; // ????
  26.     int quantity = 0; //quantity of tickets
  27.     double price = 0; //price of the movie
  28.  
  29.     MOVIES movie[MAX] = //keep info of movie
  30.     {
  31.         { Title, UCPNumber, quantity, price },
  32.     };
  33.  
  34.    
  35.  
  36.     PrintMenu(); //print and get the main menu info
  37.  
  38.  
  39.     printf("\t\tpress enter to leave"); //exits the program
  40.     getchar(); // get enter key from user
  41. }
  42.  
  43. void GetStuff(MOVIES* movie) //get info & (check if it was already there) <- not done yet
  44. {
  45.     char ch[500], movietitle[20];
  46.     FILE* fpw;
  47.     fpw = fopen("D:\\prgfiles\\labproject.txt", "ab");
  48.     getchar();
  49.     printf("\ngive me the name for the movie: ");
  50.     gets(movie->Title);
  51.     printf("\ngive me the UCP/SKU Number for the movie: %s : ", movie->Title);
  52.     scanf("%s", &movie->UCPNumber);
  53.     printf("\ngive me the quantity for the movie: %s : ", movie->Title);
  54.     scanf("%d", &movie->quantity);
  55.     printf("\ngive me the price for the movie: %s : ", movie->Title);
  56.     scanf("%lf", &movie->price);
  57.     fwrite(movie, sizeof(MOVIES), 1, fpw);
  58.    
  59.  
  60.     if (fpw == NULL)
  61.     {
  62.         printf("Error");
  63.         exit(1);
  64.     }
  65.    
  66.     gets(ch);
  67.     fputs(ch, fpw);
  68.     fclose(fpw);
  69. }
  70.  
  71. void DisplayMoviesInfo(MOVIES* movie)
  72. {
  73.    
  74.    
  75. }
  76.  
  77.  
  78.  
  79. void PrintMenu(void)
  80. {
  81.     char choose;
  82.     printf("\n\n\t\tChoose a action.\n\n");
  83.     printf("\t(A)dd a New Movie\n");
  84.     printf("\t(C)hange a Movie's Information\n");
  85.     printf("\t(D)elete a Movie\n");
  86.     printf("\t(L)ist All Movies \n");
  87.     printf("\t(Q)uit \n");
  88.     printf("\ttype the letter required to do such action:");
  89.     scanf("%c", &choose);
  90.  
  91.     switch (choose)
  92.     {
  93.     case'A':
  94.     case 'a':
  95.     {
  96.        
  97.        
  98.         printf("\n\tYou chose Add a new movie\n");
  99.         char Title[30]; // title of movie
  100.         char UCPNumber[12]; // ????
  101.         int quantity = 0; //quantity of tickets
  102.         double price = 0; //price of the movie
  103.  
  104.         MOVIES movie[MAX] = //keep info of movie
  105.         {
  106.             { Title, UCPNumber, quantity, price },
  107.         };
  108.        
  109.        
  110.          GetStuff(&movie);
  111.          
  112.            
  113.      getchar();
  114.     PrintMenu();
  115.     }
  116.     break;
  117.     case'C':
  118.     case'c':
  119.     {
  120.         printf("\n\tYou chose Change a Movie's Information\n");
  121.     }
  122.     break;
  123.     case'D':
  124.     case'd':
  125.     {
  126.         printf("\n\tYou chose Delete a Movie\n");
  127.     }
  128.     break;
  129.     case'L':
  130.     case'l':
  131.     {
  132.         char Title[30]; // title of movie
  133.         char UCPNumber[12]; // ????
  134.         int quantity = 0; //quantity of tickets
  135.         double price = 0; //price of the movie
  136.  
  137.         MOVIES movie[MAX] = //keep info of movie
  138.         {
  139.             { Title, UCPNumber, quantity, price },
  140.         };
  141.        
  142.         DisplayMoviesInfo(movie);
  143.  
  144.  
  145.     }
  146.     break;
  147.     case'Q':
  148.     case'q':
  149.     {
  150.         printf("\n\tYou chose To QUIT\n");
  151.     }
  152.     break;
  153.  
  154.     default:
  155.     {
  156.         printf("\nyou chose a wrong character\n");
  157.  
  158.     }
  159.     break;
  160.     }
  161.  
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement