123
int a = 5; char file[] = "file" + a + ".txt"; remove(file);
1234567891011121314
#include <string> #include <iostream> int main() { int a = 5; std::string filename = "file" + std::to_string(a) + ".txt"; std::cout << "The filename is: " << filename << std::endl; // if you need a const char*: const char* ptr = filename.c_str(); std::cout << "As a pointer: " << ptr << std::endl; }