SlideShare a Scribd company logo
1 of 3
Download to read offline
// Problem 2
// create some sample songs
struct Song* s1 = createSong(1, "Shape of You", "Ed Sheeran", "Pop", 2017);
struct Song* s2 = createSong(2, "Despacito", "Luis Fonsi", "Pop", 2017);
struct Song* s3 = createSong(3, "Uptown Funk", "Mark Ronson ft. Bruno Mars", "Pop",
2014);
// create the playlist and add the sample songs
struct Song* playList = NULL;
add_song(&playList, s1);
add_song(&playList, s2);
add_song(&playList, s3);
// print the playlist
printf("Initial Playlist:n");
printPlaylist(playList);
// add a new song to the playlist
struct Song* s4 = createSong(4, "Sorry", "Justin Bieber", "Pop", 2015);
printf("nAdding new song to playlist:n");
add_song(&playList, s4);
printPlaylist(playList);
// delete a song from the playlist
printf("nDeleting a song from the playlist:n");
struct Song* sToDelete = search_song(playList, "Despacito");
if (sToDelete != NULL)
{
delete_song(playList, sToDelete->name);
printf("Playlist after deletion:n");
printPlaylist(playList);
}
else
{
printf("Song not found in playlist.n");
}
// search for a song that doesn't exist in the playlist
printf("nSearching for a song that doesn't exist in the playlist:n");
struct Song* searchResult = search_song(playList, "Non-existent Song");
if (searchResult != NULL)
{
printf("Found song:n");
printf("Song ID: %d, Song Name: %s, Singer Name: %s, Genre: %s, Year: %d",
searchResult->id, searchResult->name, searchResult->singer, searchResult->genre,
searchResult->year);
}
else
{
printf("Song not found in playlist.n");
}
// search for a song that exists in the playlist
printf("nSearching for a song that exists in the playlist:n");
searchResult = search_song(playList, "Uptown Funk");
if (searchResult != NULL)
{
// printf("Found song:n");
// printSong(searchResult);
}
else
{
printf("Song not found in playlist.n");
}
// edit a song in the playlist
printf("nEditing a song in the playlist:n");
int editResult = edit_song(playList, "Shape of You", "Ed Sheeran", "Pop", 2018);
if (editResult == -1)
{
printf("Song not found in playlist.n");
}
else
{
printf("Playlist after edit:n");
printPlaylist(playList);
}
return 0;
}
*****************************************************************************
Please help me fishing this code :((

More Related Content

More from keshavagg1122

1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
 1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf 1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
keshavagg1122
 
(Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
 (Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf (Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
(Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
keshavagg1122
 
Exemplar 6.A � the concept of FE1. Define the followin.pdf
          Exemplar 6.A � the concept of FE1. Define the followin.pdf          Exemplar 6.A � the concept of FE1. Define the followin.pdf
Exemplar 6.A � the concept of FE1. Define the followin.pdf
keshavagg1122
 

More from keshavagg1122 (16)

1. Code a menu driven program in python to implement doubly linked li.pdf
 1. Code a menu driven program in python to implement doubly linked li.pdf 1. Code a menu driven program in python to implement doubly linked li.pdf
1. Code a menu driven program in python to implement doubly linked li.pdf
 
1) Exponential Distribution a) The amount of time until the next ea.pdf
 1) Exponential Distribution a) The amount of time until the next ea.pdf 1) Exponential Distribution a) The amount of time until the next ea.pdf
1) Exponential Distribution a) The amount of time until the next ea.pdf
 
1. An Overview of Ethics ( 25 Marks) 1.1 Overview of the organizati.pdf
 1. An Overview of Ethics ( 25 Marks) 1.1 Overview of the organizati.pdf 1. An Overview of Ethics ( 25 Marks) 1.1 Overview of the organizati.pdf
1. An Overview of Ethics ( 25 Marks) 1.1 Overview of the organizati.pdf
 
1. An Overview of Ethics ( 25 Marks) 1 1.2 1.3 1.4 Ethical issues i.pdf
 1. An Overview of Ethics ( 25 Marks) 1 1.2 1.3 1.4 Ethical issues i.pdf 1. An Overview of Ethics ( 25 Marks) 1 1.2 1.3 1.4 Ethical issues i.pdf
1. An Overview of Ethics ( 25 Marks) 1 1.2 1.3 1.4 Ethical issues i.pdf
 
1. A company called XYZ Inc. has recently migrated its entire infrast.pdf
 1. A company called XYZ Inc. has recently migrated its entire infrast.pdf 1. A company called XYZ Inc. has recently migrated its entire infrast.pdf
1. A company called XYZ Inc. has recently migrated its entire infrast.pdf
 
1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
 1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf 1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
1) La idiotez amaur�tica infantil (enfermedad de Tay Sachs) es un.pdf
 
1 Give three (3) properties of viruses. [3] 2 With the aid of an appr.pdf
 1 Give three (3) properties of viruses. [3] 2 With the aid of an appr.pdf 1 Give three (3) properties of viruses. [3] 2 With the aid of an appr.pdf
1 Give three (3) properties of viruses. [3] 2 With the aid of an appr.pdf
 
1 - �Qu� t�rmino se refiere a la forma en que vemos el mundo y damo.pdf
 1 - �Qu� t�rmino se refiere a la forma en que vemos el mundo y damo.pdf 1 - �Qu� t�rmino se refiere a la forma en que vemos el mundo y damo.pdf
1 - �Qu� t�rmino se refiere a la forma en que vemos el mundo y damo.pdf
 
(Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
 (Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf (Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
(Reporting entity) (Note Exercises E9-39 through E9-41 are based on .pdf
 
(is) is more ecenomical, wath a daily holding cost of I b) What issue.pdf
 (is) is more ecenomical, wath a daily holding cost of I b) What issue.pdf (is) is more ecenomical, wath a daily holding cost of I b) What issue.pdf
(is) is more ecenomical, wath a daily holding cost of I b) What issue.pdf
 
(5 pts) The work by Davies et al. (2007) examined the affects of vari.pdf
 (5 pts) The work by Davies et al. (2007) examined the affects of vari.pdf (5 pts) The work by Davies et al. (2007) examined the affects of vari.pdf
(5 pts) The work by Davies et al. (2007) examined the affects of vari.pdf
 
(b) Let X and Y be independent random variables each with uniform d.pdf
 (b) Let X and Y be independent random variables each with uniform d.pdf (b) Let X and Y be independent random variables each with uniform d.pdf
(b) Let X and Y be independent random variables each with uniform d.pdf
 
(4.24) Irmagine that you test your patient and determine that there i.pdf
 (4.24) Irmagine that you test your patient and determine that there i.pdf (4.24) Irmagine that you test your patient and determine that there i.pdf
(4.24) Irmagine that you test your patient and determine that there i.pdf
 
Manny Gill is an entrepreneur who started West Secure, a business t.pdf
   Manny Gill is an entrepreneur who started West Secure, a business t.pdf   Manny Gill is an entrepreneur who started West Secure, a business t.pdf
Manny Gill is an entrepreneur who started West Secure, a business t.pdf
 
Exemplar 6.A � the concept of FE1. Define the followin.pdf
          Exemplar 6.A � the concept of FE1. Define the followin.pdf          Exemplar 6.A � the concept of FE1. Define the followin.pdf
Exemplar 6.A � the concept of FE1. Define the followin.pdf
 
(10 points) Two people trade two goods that they cannot produce. Supp.pdf
 (10 points) Two people trade two goods that they cannot produce. Supp.pdf (10 points) Two people trade two goods that they cannot produce. Supp.pdf
(10 points) Two people trade two goods that they cannot produce. Supp.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 

Problem 2 create some sample songs struct Song.pdf

  • 1. // Problem 2 // create some sample songs struct Song* s1 = createSong(1, "Shape of You", "Ed Sheeran", "Pop", 2017); struct Song* s2 = createSong(2, "Despacito", "Luis Fonsi", "Pop", 2017); struct Song* s3 = createSong(3, "Uptown Funk", "Mark Ronson ft. Bruno Mars", "Pop", 2014); // create the playlist and add the sample songs struct Song* playList = NULL; add_song(&playList, s1); add_song(&playList, s2); add_song(&playList, s3); // print the playlist printf("Initial Playlist:n"); printPlaylist(playList); // add a new song to the playlist struct Song* s4 = createSong(4, "Sorry", "Justin Bieber", "Pop", 2015); printf("nAdding new song to playlist:n"); add_song(&playList, s4); printPlaylist(playList); // delete a song from the playlist printf("nDeleting a song from the playlist:n"); struct Song* sToDelete = search_song(playList, "Despacito"); if (sToDelete != NULL) { delete_song(playList, sToDelete->name); printf("Playlist after deletion:n"); printPlaylist(playList); } else { printf("Song not found in playlist.n"); } // search for a song that doesn't exist in the playlist printf("nSearching for a song that doesn't exist in the playlist:n");
  • 2. struct Song* searchResult = search_song(playList, "Non-existent Song"); if (searchResult != NULL) { printf("Found song:n"); printf("Song ID: %d, Song Name: %s, Singer Name: %s, Genre: %s, Year: %d", searchResult->id, searchResult->name, searchResult->singer, searchResult->genre, searchResult->year); } else { printf("Song not found in playlist.n"); } // search for a song that exists in the playlist printf("nSearching for a song that exists in the playlist:n"); searchResult = search_song(playList, "Uptown Funk"); if (searchResult != NULL) { // printf("Found song:n"); // printSong(searchResult); } else { printf("Song not found in playlist.n"); } // edit a song in the playlist printf("nEditing a song in the playlist:n"); int editResult = edit_song(playList, "Shape of You", "Ed Sheeran", "Pop", 2018); if (editResult == -1) { printf("Song not found in playlist.n"); } else { printf("Playlist after edit:n"); printPlaylist(playList); }