I have a function which takes a const char*
argument. I need to concatenate two string literals and an int
to pass to this argument. Basically this is what I'm trying to do:
open(const char* filename) {}
void loadFile(int fileID)
{
open("file" + fileID + ".xml");
}
int main()
{
loadFile(1);
return 0;
}
How can I make this work as simply as possible? I tried changing the loadFile function to take a const char*
and then doing open(std::string("file").c_str() + fileID + std::string(".xml").c_str());
but then I get error: invalid operands of types 'const char*' and 'const char*' to binary 'operator+'
so I'm pretty lost.