c++ program take string input,place in two vectors,separate columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acs7737
    New Member
    • Oct 2008
    • 2

    c++ program take string input,place in two vectors,separate columns

    i have this hw problem for class thats supposed to read a comma separated list of my cd collection
    ex.: artist,album
    artist,album
    artist,album
    it reads that into a string and then has to separate the artists into one vector and the album into another and then place the artist vector in one column and the album vector into another column
    i think i can do the column part but i have no clue how to separate the whole thing into two vectors. could you please give me some suggestions on how to do this.
    thanks
  • Studlyami
    Recognized Expert Contributor
    • Sep 2007
    • 464

    #2
    How would you solve this problem in real life (not thinking about programming).

    You would have a CD collection
    In your CD collection you would have multiple artists and you could have multiple cd's from an artist. Break the assignment down into steps and post them here. Also, you can have a vector of a vector perhaps this can help. Break this down into steps and work out some code and post that as well and we will help guide you where you get stuck. Good Luck!

    Comment

    • acs7737
      New Member
      • Oct 2008
      • 2

      #3
      yea i understand the assignment i just dont know how to break the input into two separate vectors. i have no clue where to even start doing that. iv got as far as declaring the vectors and the string and reading the input into the string and thats it, i need to know where to go from there.
      thanks

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Each record in the file has an artist and an album. One artist can have many albums.

        Fist associate the artist with the album. Research the pair<> container.

        Then create a vector of pairs.

        Comment

        Working...