Basic C

Write a file named song.csv that stores a list of song in common-sparated format.  Each line in the file should contain the following fields: song name, artist, and album name.  The fields should be separated by commas.

An example file might look like this:

song1,artist1,album1
song2,artist1,album1
song3,artist1,album1
song4,artist2,album2

Write a program in a file named playlist.c that takes a file name as an argument.  The program should read the contents of the file into an array where each index in the array stores a song object.  The song object should be defined using a struct.  Therefore the type of the array should be an array of structs.

After reading in the input file, the program should enter an infinite loop.  When in the loop, the program should display the following menu:

  1. Add song
  2. Remove song
  3. List songs
  4. Exit

The program should wait for the user to enter an input and then read in the input.

If the user enters 1, the program should prompt the user for song information and add an entry to the array.

If the user enters 2, the program should prompt the user for song information and remove the entry from the array.

If the user enters 3, the program should display on the screen the songs stored in the array.

If the user enters 4, the program should write the contents of the array to the file, overwriting the current contents, and then exit the program.

© 2017, Eric. All rights reserved.