If I encounter the desired string in a file, how can I get the program to basically continue and write the next lines in a new vector?
This is what I did:
The thing is, the only line I get in the ITQuestions vector is IT:
After that, the next questions are written in the BQuestions vector. I know this is basically what I told it to do, find IT:, write it in the ITQuestions vector and then continue what it was doing, but I have no idea how to make this work. Please, help? xD
Thanks in advance,
BreaKer.
Replace "continue" with another loop that reads from the file into your vector. This tells the program to enter that read-to-vector loop after finding the "IT:" string.
The thing is, if I do the loop after the IF statement, it starts from the head of the file, not from the IT: part, so it writes all of it both in the ITQuestions and BQuestions...
That won't happen if you use the same stream that you do in the previous read-in loop.
Alternativley you can read the whole file into memory and parse it afterward. This might seem like it would take a while but trust me, it won't. It also makes working with the data ten times easier because at that point it's just data in memory, there's no need to worry about the source file.
So you mean read the whole file in a Vector, then decompose the vector in multiple vectors, right?
The problem is, I'm kinda' new in the business, so I am not really sure how can I do that.
Maybe a strstr to find the IT: and then a for loop to strcpy it to another vector and so on?
I'll give it a try :)
Thanks again for your time!
Considering that the second part it's kinda hard for me, I tried with the read loop as you said and it worked! I can't thank you enough xD
Thanks again for your time,
BreaKer.