Trouble reading in info

I'm working on a program that reads in data from a list of music albums, and then swaps the songs and albums into alphabetical order.

Information:http://pastebin.com/71TTySuV

So far this is what I have. There aren't any errors with this build so far, but I'm certain it's not reading into the correct variables as intended.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
struct album{
string artist;
string year;
string genre;
string songs[12];
};
int main()
{
char calbum[4];
    string artist,year,genre,song;

     while (cin.good())
      {
        string album = calbum;
        cin >> album >> artist >> year >> genre;

        cout << album << endl;
        cout << artist << endl;
        cout << year << endl;
        cout << genre << endl;
      }
    return 0;



}


I'm not quite sure on how I could change the way I'm reading in the information. I'm fairly new to c++ and any and all help would be great.
If you only want to write to stdout what you get from stdin, then your program works fine for me.

If you want to fill a variable of type album you have to define one. F.e.:
album myAlbum;
The definition should be outside of the while-loop, because otherwise you'll lose it after leaving the loop.

If you want to fill an array of album you have to define it. F.e.:
1
2
const unsigned int albumSize(10);
album myAlbums[albumSize];

In this case you may need some index or pointer to remember the next unused slot.
Topic archived. No new replies allowed.