I have a series of files ( New1.BMP, New2.BMP, ...,New10.BMP).
I need to create a variable that stores the name of the above files and then use it in another code.
My current code:
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)); } As you might see, I have no clue how to code in C++, I have tried to make this work from code snippets online. Is this how it is supposed to work in C/C++, i.e. on the fly creation of variables.
How do I best approach it?
itoa. In C++, this is simplystd::string name = "New" + std::to_string(l) + ".BMP";