Computer science C Programming help. I have an example pseudocode:

SoccerBoss
Category:
Computer Science
Price: $10 USD

Question description

1. The program should open the first file name given on the command line (NOT stdin). The file will contain a list of the format (name, price, number in stock ). For example:

         Call of Duty 16, 9.99, 12
         Skyrim Super Amazing Legendary Edition, 19.99, 8
         Left for Dead 6, 75.00, 3

A sample program execution is:

         a.out inputfile outputfile

There can be any number of games in the file. Make sure your dynamic arrays can shrink and grow to fit the data.

2. In the file, dynamicarray.c, write the code necessary to complete the assignment.

(a) The program should first print the inventory with numbers and a command prompt:

            1. Call of Duty 16, 9.99, 12
            2. Skyrim Super Amazing Legendary Edition, 19.99, 8
            3. Left for Dead 6, 75.00, 3
            COMMAND:

(b) When the user types a number, it should subtract 1 from the number in stock for that game. For example:

COMMAND: 2

would result in the following output:

               1. Call of Duty 16, 9.99, 12
               2. Skyrim Super Amazing Legendary Edition, 19.99, 7
               3. Left for Dead 6, 75.00, 3
               COMMAND:

The number of in stock for a game cannot go below 0. If the user tries to remove a game that has 0 stock, the program should print an error message. For example if Left for Dead had 0 stock, it would print:

              1. Call of Duty 16, 9.99, 12
              2. Skyrim Super Amazing Legendary Edition, 19.99, 7
              3. Left for Dead 6, 75.00, 0
              COMMAND: 3
              ***ERROR: 3. Left for Dead 6 is OUT OF STOCK

(c) When the user types ’q’, the current inventory should then be printed to the output file (i.e., the second filename given on the command line) in the same format as the input file (name, price, number in stock). Then the program will terminate.

3. The program should free all storage allocated before it terminates. Run your program under valgrind to verify that you have no memory leaks or other errors. For example:

valgrind a.out inputfile outputfile
Your valgrind output should look something like:

  ==1239==
  ==1239== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 1)
  ==1239== malloc/free: in use at exit: 0 bytes in 0 blocks.
  ==1239== malloc/free: 23 allocs, 23 frees, 100,400,748 bytes allocated.
  ==1239== For counts of detected errors, rerun with: -v
  ==1239== All heap blocks were freed -- no leaks are possible.

Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1823 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors