Question: Write a C program; The program takes its input from a .txt file specified as an argument to the program. If the file does not

Write a C program;

The program takes its input from a .txt file specified as an argument to the program. If the file does not exists or is not readable, the program prints out an error message to this effect. If no file is specifed, the program searches in the current directory for a file called songs.txt. If no file exists, the program prints a message No file. and then prompts the user to enter the artists and songs information from the keyboard.

Your program should then sort the input by artiste name and then by song title and print it out

The program should then generate a random playlist of the songs given as input, according to the following constraints:

An artist cannot have more than two songs in a row

A song cannot appear twice in the playlist;

The total playlist length should be as close as possible to one hour.

an example of the input file is:

The National Fireproof***2:58 Hard to Find***4:13 England***5:40 Son***5:20 Light Years***3:32 Lean***4:31 The System Only Dreams in Total Darkness***3:56

Arcade Fire Rebellion (Lies)***5:10 Wake Up***5:39 Cold Wind***3:12 Neighborhood #1 (Tunnels)***4:48 Neighborhood #3 (Power Out)***5:12

The War on Drugs Under the Pressure***8:51 Red Eyes***4:58

Sufjan Stevens Go! Chicago! Go! Yeah!***6:04 Chicago [To String Remix]***5:32 Carrie & Lowell***3:14 John My Beloved***5:03

London Grammar Wasting My Young Years***3:24 Strong [Hackman remix]***5:13

Jos Gonzlez Heartbeats***2:40

Bon Iver 29 #Strafford APTS***4:05 00000 Million***3:53 re: Stacks***6:40 Future Islands Tin Man***3:14 Seasons (Waiting on You)***3:46 Grease***4:35 Spirit***4:22

Public Service Broadcasting They Gave Me A Lamp***3:56 The Other Side***6:20 Go!***4:13

OUTPUT :

Randomised playlist

Public Service Broadcasting: "They Gave Me A Lamp" (3:56)

The War on Drugs: "Under the Pressure" (8:51)

Future Islands: "Spirit" (4:22)

Arcade Fire: "Cold Wind" (3:12)

The National: "England" (5:40)

Bon Iver: "re: Stacks" (6:40)

Sufjan Stevens: "Chicago [To String Remix]" (5:32)

Jos Gonzlez: "Heartbeats" (2:40)

Public Service Broadcasting: "The Other Side" (6:20)

Public Service Broadcasting: "Go!" (4:13)

Arcade Fire: "Rebellion (Lies)" (5:10)

London Grammar: "Wasting My Young Years" (3:24)

Total duration: 60:00.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!