I have the following text file:
-
DC's Legends of Tomorrow
-
Ice Age 5: Collision Course
-
Miss Peregrine's Home for Peculiar Children
-
Forbidden Empire
-
The Zero Theorem
-
X-Men: Days of Future Past
-
Jupiter Ascending
-
The Mortal Instruments: City Of Bones
-
The Age of Adaline
-
Melancholia
Each entry has a line of blank space between them. I am trying to read through the file and save each movie into an array of strings. I am getting the error: Debug Assertion Failed! Expression: String substring out of range
Here is my code:
void readFile() {
ifstream in_stream;
int numberLines = 10;
string movieName;
int movieNum;
string movieList[10];
in_stream.open("input.txt");
for (int i = 0; i < 10; i++)
{
in_stream >> movieNum >> movieName;
movieList[i] = movieName;
}
in_stream.close();
}
Aucun commentaire:
Enregistrer un commentaire