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

  Advanced systems analysis and designtasks 1 - produce a

advanced systems analysis and designtasks 1 - produce a system specification indicating functional and non-functional

  Library inventory using a client-server model

Library inventory using a client/server model. LIMS should allow multiple clients to safely access the inventory, and using a producer-consumer model to borrow/return library items.

  Problem 1given n courses along with their course strength

problem 1given n courses along with their course strength and m examination halls along with their capacity assign the

  Singly linked list

Singly Linked List (SLL)Introduce a SLL class with the following functions. Please also introduce a main function that will invoke and verify whether the functions are implemented correctly

  Write algorithm for program to compute the sum of number

Write an algorithm for a program which will satisfy following requirements: - Asks a user how many numbers they want to calculate.

  Adopting agile development methodologies

Relative advantages are the degree to which a new technology is perceived to be superior to current technology. An company is more likely to adopt new technology when it perceives greater relative

  Describe sorting algorithm to be parsimonious

Describe a sorting algorithm to be parsimonious if it never compares same pair of input values twice. (Supose that all the values being sorted are distinct.).

  What items do we require for a small business wlan what

imagine that you work at a small company with 75 employees in a modern office building. some of the employees are eager

  Use sequential search algortithm to locate the number

These numbers should be stored in an array. Use the sequential search algortithm to locate the number entered by the user. If the number is in the array, the program should display a message.

  Time n-processor common crcw pram algorithm

present an O(1) time n-processor common CRCW PRAM algorithm for computing the boolean AND of n bits.

  Discuss infix to postfix conversion

This part will use both a stack and queue in order to convert expressions from infix to postfix notation.

  Discuss the business problem

Provide a clear statement of the aims and objectives of the data analytics study and the possible outcomes in terms of discovered knowledge and its potential application towards solution of the problem. In this section you need to discuss the busi..

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