I have a casting problem. I am writing a code to open all the files that are in a folder and have a common name, but with a number that make them different. Let's see this in an easier way with examples. The name of one file will be Table1.txt, another one Table2.txt, another one Table3.txt and so on.
So I'm writing something like this:
int TableId;
for(TableId=1;TableId<=7;TableId++) // We suppose that we have seven different files in my folder.
// Could I make something simmilar to open all the files with these characteristics?
{
string folder("C:\\example\\"); // Folder where my different files are stored in ".txt" files.
string Id; // Casting conversion
Id = (char) TableId;
folder += "Table";
folder += Id;
folder += ".txt"; // Extension of the file
ifstream ifs(folder.c_str());
}
The problem is that my code compiles perfectly, but when it runs, it's not in the best way. When I add to the string folder the string Id, my code doesn't understand it in the good way. How do I solve it?
Could I make something so that I could open all the files with the same characteristics, as the files I'm trying to open?