If your files are located in a single directory, or a directory with subdirectories, iterating for files with C++17's <filesystem> library would make it easier to deal with multiple files.
@thmm: Thanks thmm, the thing is that I have already tried this and it doesn't work. For some reason it sticks with the
if (!src) { cout << error open file" <<endl;}
, plus, I have a long list of files (400) and therefore, since I have to store each data I read to a vector, I will have to break it into three vectors (0-9, 10-99, 100-400) and then concatenate the three vectors.
@seeplus: Thanks a lot seeplus. I created another post with my code so far, with the name <<Plz your help!>>. I have the code there with the explanation of what I want to do, if you would like to advice me on that. Thanks in advance
@againtry: Thanks againtry. basically the files are already present, I don't have to set them up, and their name is dataK, where K starts from 000 and ends up to 150. In addition, I didn't quite understand the following:
You probably shouldn’t be reading all those files with a single stream object. If you find yourself calling open/close on fstream’s, you’re likely doing it wrong.
You wouldn’t create hundreds of stream objects at the same time, you’d create the one at a time on demand.
Let the constructor initialize the object and the destructor cleanup.
This may give you insight to treat the streams more generally, and use the Creator pattern to instantiate the right kind of stream. Dunno what your exact requirements are, but it’s often worth thinking more widely about such things.
EDIT: Thanks to IOS autocorrect for making my spelling even worse.
Thank you for the code and I apologize for creating to many topics, I just thought that since are different (even though they were on the general same topic of pairs) it would be good not to mess them up.
Could you please give me an idea on the following as seeplus did help me but the cout was not obtaining the pairs as pairs?
Suppose we have a vector of pairs like the following:
My question is, if we would like to find the first (or last) two consecutive pairs in the vector of pairs with greatest equal second, namely here pairs (3,50) and (8,50), and obtain them and store them in different pair variables sperately, i.e