I want to concatenate three string in C++.
I have a vector std::vector<std::string> my_list
where the filenames are stored. I want to add the directory and filename extension for each of the filenames in order to read binary the information from the file, so i do it like that:
for (int i = 0; i < my_list.size(); i++) {
std::string tmp = prefix + my_list[i] + suffix;
std::ifstream file(tmp.c_str(), std::ifstream::binary);
}
where prefix ist std::string prefix = "directory/" and suffix ist std::string suffix = ".foo".
And it works in Windows. However it doesn't work in Linux.
Suffix overwrites "tmp"-string. It looks like foo/y_file_timestamp
instead of out/my_file_timestamp.foo
.
What should I do to prevent this overwriting?