|
| |||||||||||||||||||||||||||||||||||||||
| RyuKazama (2) | |||
|
Basically as the title suggests. Basically, I have a text file (lyrics or subtitles, say) set out as so: 00:04:00 00:09:00 XXXXXXXXXXXXX Where the ints are times (start and end times) and XXXXXXXX being the string. How then would I be able to store this data into a vector? I have a similar example where the text file uses years (ie 2000 2010 XXX) and I was able to store this in a vector and print to console without issues.
I also need a way that I can use time as an input so the words can show up based on the times from the text file (ie at 4 seconds line 1 is printed, at 7 seconds line 2....and so on). Thank you for your help. | |||
|
|
|||
| firedraco (4744) | |
| The reason you can't do it right now is because the >> operator will read up to a space (or a newline) and then stop, however in this case you want to read up to the next ':'. I would suggest using std::getline() first, then parsing the string yourself with .find() and .substr(). | |
|
|
|
| RyuKazama (2) | |
|
Thanks, I'll take a look into that. I forgot to mention though that I get an error of "vector out of bounds". If I just gave main() a simple thing (a cout, for example) it compiles fine. So something in the for loop is giving me my error. Also, even if the file formats has no use ':' and just ints, I still get the error. | |
|
Last edited on
|
|
| Bazzy (6258) | |
for(int i=0; i <= lyrics.size(); i++){ remove the equals sign from the comparison : for(int i=0; i < lyrics.size(); i++){ | |
|
|
|