Reading Data Into Structures

I'm having difficulty reading data into a struct.

Here is an example of the data:
1
2
3
4
5
6
7
8
9
10
11
Journey 2: The Mysterious Island
February 10, 2012
Josh Hutcherson
Dwayne Johnson
Michael Caine 

Project X
March 2, 2012     
Thomas Mann
Oliver Cooper
Jonathan Daniel Brown


Here is an example of my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
struct movies
{
        string name;
        string data;
        string stars[10];
        int count;
}

movies wb[10];

string st;
while(getline(cin, st)) {
}


It's been a long time since I've worked in C++, and my primary problem is knowing how to split up the code into that structure line by line. No outside file reading is necessary.

Thanks for your help.
So that data is something that u type in directly ? This code can be improved lots. It's just to give an idea:
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
29
30
31
32
struct movies
{
        string name;
        string data;
        string stars[10];
        int count;
}
int main()
{
movies wb[10];
string st;

int i = 0;

while(i<10) {
   cout >> "Enter a title: ";
   getline(cin, st);
   wb[i].name = st;
   cout >> "Enter the date: "
   getline(cin, st);
   wb[i].data = st;
   cout >> "Enter 3 stars: ";
   getline(cin, st);
   wb[i].stars[i] = st;
   getline(cin, st);
   wb[i].stars[i+1] = st;
   getline(cin, st);
   wb[i].stars[i+2] = st;
   i += 1;
}
return 0;
}
Last edited on
No it's a file with data like the example I gave I read in with the command to run the program.
Topic archived. No new replies allowed.