/* Author: Susan Mitchell */ /* File : Cd.c */ #include #include #include #include "Cd.h" Cd* createCd(char *artist, char* title, int month, int day, int year, int numInStock, float price) { Cd* temp = (Cd*) malloc(sizeof(Cd)); temp->artist = (char*) malloc(strlen(artist) + 1); strcpy (temp->artist, artist); temp->title = (char*) malloc(strlen(title) + 1); strcpy (temp->title, title); temp->dateReceived.month = month; temp->dateReceived.day = day; temp->dateReceived.year = year; temp->numInStock = numInStock; temp->price = price; return (temp); } void destroyCd(Cd* aCd) { free (aCd->artist); free (aCd->title); free (aCd); } void printCd(Cd* aCd) { printf ("%-25s %-25s %02d/%02d/%d %3d %1.2f\n", aCd->artist, aCd->title, aCd->dateReceived.month, aCd->dateReceived.day, aCd->dateReceived.year, aCd->numInStock, aCd->price); }