I am new to C++, and I would be very grateful if you could help me out.
I've a series of files from which I have to extract data from. They have similar names, the only thing that differs is a number, for example file1.txt, file2.txt..., up to 50.000.
I've already defined a code that passes a number (from a counter) to a char, that is later concatenated, giving me the file name that is used in a procedure to extract the data. As showed in the code below.
But after 5 loop iterations the program is not able to open the files anymore and it says that the program has encoutered an error and needs to close. What is wrong with my code? How can I make it work?
Many thanks for your help.
char name = "HIV_HPV_calib.pkg_Global_";
char end = ".txt";
for (int gh=1; gh <51; gh++)
i = gh;
snprintf(buf, sizeof(buf), "%d", i);
snprintf(buf, sizeof(buf), "%s%d%s", name, i , end);