我有一系列文件(New1.BMP,New2.BMP,...,New10.BMP).
我需要创建一个存储上述文件名称的变量,然后在另一个代码中使用它.
我目前的代码:
int LengthFiles =10;
char FilePrefix[100]="New";//This is actually passed to the function. Am changing it here for simplicity
char str[200],StrNumber[1];//str holds the file name in the end. StrNumber is used to convert number value to character
SDL_Surface *DDBImage[9]; // This is a SDL (Simple DIrectMedia Library) declaration.
for (int l=0;l<LengthFiles ;l++)
{
itoa(l, StrNumber, 1);
strcat(str,FilePrefix);strcat(str,StrNumber);strcat(str,".BMP");
DDBImage[l]= SDL_DisplayFormat(SDL_LoadBMP(str));
}
Run Code Online (Sandbox Code Playgroud)
正如您可能看到的,我不知道如何用C++编写代码,我试图通过在线代码片段来完成这项工作.这是它应该如何在C/C++中工作,即即时创建变量.
我该如何最好地接近它?