A problem with reading multiple lines from a file
Hello, i have a file that holds details about movies and i want to read these details into an array in my program. The file layout is this:
1 //number of films recorded
Pulp Fiction //title
Tarantino //director
5 //current position
100 //total length
in my program i have the following code to read in this data:
Code:
fin >> numOfMP3s;
while (count !=numOfMP3s)
{
fin.getline(title,50);
fin.getline(director,50);
fin >> currentPosition;
fin >> length;
cout << length;
}
the number of mp3s is read in correctly(first line in the file) however the others are not. when i cout title or director nothing is displayed and when i cout either of the integer values i get the value -858993460 printed out.
any ideas? the only tutorials i could find deal with just simple file reading.
thanks in advance :)