Define a structure type

Assignment Help Data Structure & Algorithms
Reference no: EM13762928

Your program must meet the following requirements:

1. Define a structure type to represent a single CD. The year must be stored as an integer, all other fields should be strings. Because memory space will be an issue you may not assume a length for the string fields, but must dynamically allocate appropriately sized strings as needed.

2. Write a function that takes a CD handle (i.e., a pointer to a pointer) and a file pointer as arguments. The file pointer should point to a file of CDs formatted as described above. The function should do the following (not necessarily in this order):
- allocate a CD for the handle to refer to
- read the next line from the specified file pointer using fgets
- use strtok and sscanf to parse the input line into the CD fields

As mentioned above, you must dynamically allocate the string fields in the CD to be exactly large enough to hold the corresponding strings. You may assume that an input line is at most 256 characters.

The function should return 0 if successful, 1 if an error occurred in parsing the line, and EOF if end-of-file was encountered.

3. Write a function that takes a CD handle argument. The function should deallocate all dynamically allocated memory associated with the CD (including the CD itself). The CD address should be set to NULL.

4. Write a function that takes a CD argument and prints out the CD to stdout in the following format (using the first CD in cds.db as an example):

The CD Astral Weeks was released by Morrison, Van in 1968 on Warner Bros.
page 1 of 2

5. Write a function that takes takes two arguments: a CD and the name of an artist. The function should return whether or not the specified CD was recorded by the indicated artist.

6. Now write a main function that takes two command-line arguments: the name of the input CD file and the name of an artist. Your main should do the following:

a. Open the indicated CD input file for reading.

b. Repeat the following for all CDs in the input file (i.e., until EOF is encountered in the
first step):

i. Use your function 2 to dynamically allocate and read-in a single CD. If your function indicates that an error has occurred in reading the CD then output an error message and exit the program.
ii. Use your function 5 to check if the CD was recorded by the artist indicated in the second command-line argument. If it was, print-out the CD using your function 4.
iii. Deallocate the CD using your function 3.

Reference no: EM13762928

Questions Cloud

Consumer sentiments in a positive direction : Do you know what are some active ways the government tries to turn consumer sentiments in a positive direction when the forecast on the news and in the actual economy looks bleak?
Assume no other income and taxes during retirement : Amanda is expected to receive full social security retirement benefit of $15500 annually when she turns 65. These benefits can be increased by 40% if she delays taking them till age 70. If her life expectancy is 90 years and expected rate of return i..
Excel for decision support modeling : Willy Wonka is considering starting a production line to produce fizzy lifting drinks. As Chief Oompa Loompa (COL) you have access to a wide variety of financial data to help you determine whether bringing the new production line on will be a sma..
Program takes input from a user in the form of a phrase : This program takes input from a user in the form of a phrase. It then converts the phrase to ig latin.
Define a structure type : Define a structure type to represent a single CD. The year must be stored as an integer, all other fields should be strings. Because memory space will be an issue you may not assume a length for the string fields, but must dynamically allocate app..
Leverage measure and about common stock : Which one of the following statements about common stock is true? Substituting EBITDA for EBIT when computing the times interest earned ratio will make the company appear. Which one of the following is a leverage measure?
Current labor cost per car sold : Suppose that a car dealership wishes to see if efficiency wages will help improve its salespeople's productivity. Currently, each salesperson sells an average of one car per day while being paid $20 per hour for an eight-hour day.
The causes of nursing home death : What are some of the causes of nursing home deaths?
Compute the combined worth of steves retirement assets : Steve is about to retire and wants to calculate the total worth of his retirement assets. He has a corporate pension paying $2250 at the beginning of every month. He is also entitled for Social Security benefits of $1450 at the beginning of every mon..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd