How to use C to make a program that can store song information? In this homework
ID: 3688633 • Letter: H
Question
How to use C to make a program that can store song information?
In this homework, you will use C struct to represent data and incrementally develop/test code for creating and managing a mp3 song database.
A mp3 song has the following information about it. A C struct should be used to hold the information below for each song. a. Title of the song - A string of at most 40 characters b. Artist names - Maximum of three artists, Each name is at most 20 characters c. Song release date - Three fields specify date - mm/dd/yyyy (month/day/year) d. Genre of song - Country or Blues or Rock or Heavy metal or Hip-Hop.
The maximum number of songs in the database is 30. An array of structs should be used here.
Create a function to insert songs with the information in Step 2 into the database. You need to input only 5 songs in this step to test this step.
Explanation / Answer
struct songData{
//a. Title of the song - A string of at most 40 characters
char title[40];
//b. Artist names - Maximum of three artists, Each name is at most 20 characters
char artistName1[20],artistName2[20],artistName3[20];
//d.Genre of song - Country or Blues or Rock or Heavy metal or Hip-Hop.
char genereOfSong;
};
//The maximum number of songs in the database is 30
songsData sd[30];
void displaySongData(struct songsData sd);
int main(){
struct songsData s1;
printf("Enter title of the song: ");
scanf("%s",&s1.title);
printf("Enter artist names:");
scanf("%d",&s1.artistName1);
printf("Enter artist name2:");
scanf("%d",&s1.artistName2);
printf("Enter artist name3:");
scanf("%d",&s1.artistName3);
Display(s1); // passing structure variable s1 as argumen
return 0;
}
void displaySongData(struct songsData sd){
printf(" title: %s",stu.title);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.