I'm trying to run several files through a simulation, where each file name has letters and numbers in them. Suppose I have four files, one1.dat, one2.dat, two1.dat, two2.dat. I'm having trouble looping through the letter part of the file names. I'm looking for something like the following code:
int fileindex=1;
loop through the letter parts of the file names (say the current one is filename) {
while(fileindex<3){
//I have been using the following code to open files, where I would write in
//"one" for filename for example
char outputArray[200];
string outputFilename = filename;
strcpy_s(outputArray,outputFilename.c_str());
stringstream num;
num<<fileindex;
strcat_s(outputArray,num.str().c_str());
strcat_s(outputArray,".dat");
ifstream data (outputArray);
//stuff...
data.close();
//more stuff
fileindex++;
}
}
Thank you both for your reply!
Helios, I guess my problem is I don't know how to store the letter parts of the file name so that I could loop through it. So filename should come from an array or a vector, but I haven't been able to figure out which one and what type.
Dhayden, I can loop through the number parts, but not the letter parts.