I am trying to load a list of image files into an image array. The following code snippet works:
Graphics gImage(hdc);
Image iTiles[intNumTiles] = {L"Image[0].jpg", L"Image[1].jpg", L"Image[3].jpg", ...};
gImage.DrawImage(&iTiles[0], 100, 50);
gImage.DrawImage(&iTiles[1], 140, 90);
gImage.DrawImage(&iTiles[1], 180, 130);
...
The problem is, I don't know how many image files there are, until a run the program, and search a folder for the files. You can see my dilemma. I came across a tool sometime back that would allow me to replace a line of code with a string name. When the program compiles, rather than seeing the string name, it actually reads in the string itself. It would look something like this:
Graphics gImage(hdc);
string sLoadFiles;
for (int i = 0; i < intNumTiles; i++)
{
sLoadFiles = sLoadFiles + ("L\"Image[%d]", i);
}
Image iTiles[intNumFiles] = {sLoadFiles};
for(int j = 0; j < intNumFiles; j++)
{
gImage.DrawImage(&iTiles, 100 + i * 40, 50 + i*40);
}
Obviously the above code is wrong, but does this sound familiar to anybody else?