I have a project completed where I read in a file and assigns the data in the txt file to a matrix. The problem I am having is that I have 8 data files named data1.txt through data8.txt. I need to find a way to loop through the the data file names by somehow incrementing the number portion of the filename. I've tried to read multiple data file using strcpy, there does not seem anything error with my program, but it can't read the file. How I can fix it? Am I wrong when using 'strcpy'?
char filename[10];
for(input = 1; input <= 5; input++){
strcpy(filename,"data."+input);
ifstream fin(filename);
}
or may be any other to read multiple data.