Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Allowed libraries: stdio.h, string.h 2. We will be creating a structure for storing DVDs in a library. 3. Create a Header file, which is

1. Allowed libraries: stdio.h, string.h 2. We will be creating a structure for storing DVDs in a library. 3. Create a Header file, which is a text file, named structures.h. Do the following in structures.h. a. Create two constants: i. TEXT_SIZE and set it to 80. ii. NUM_DVDS set it to 4. b. Create a typedef structure named dvd_t which has a field for the title which is TEXT_SIZE in length called title, a field for director which is TEXT_SIZE in length called director, and an integer for play time of the DVD in minutes named playTime. The fields MUST be named exactly as shown above otherwise the tests will fail. You MUST create a "typedef struct" as shown in the notes or your tests will fail. c. Add prototypes for the methods created below. A prototype is simply the function declaration without the body. You can wait till you finish the functions to add them if you wish. Here is an example prototype. int getMask(int start_bit, int end_bit, int bit_value);

The above is more of a prereq for this problem, below is the problem.

b. Create a function named getOneDVD which takes a reference to a dvd_t as a parameter. This function should get a single title, director, and play time from the terminal using scanf and put that data into the dvd_t structure. Use EXACTLY the prompts as shown in the sample output. Notice there is ONE single space after the colon. NOTE ON SCANF AND SPACES. You have to tell scanf to allow spaces otherwise it will stop scanning when it hits a space. The following should work: char test[11]; scanf("%10[^ ]s", test); char c; scanf("%c", &c); //Of course you have to get rid of the newline now. The above shows reading a string which is at the most 10 characters in length. Yours will be a different length. The [^ ] means not a newline. It will accept characters up to, but not including a newline. This will allow you to have spaces in the input string. The scanf stops when the newline is reached (i.e. the enter key is pressed) so you must remove the newline from the scanf queue which is what the second scanf above demonstrates. You ONLY have to get rid of the newline after reading strings. Dont read the character after scanning an int or double.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago