fork(1) download
  1.  
  2. #include <string>
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7. int a = 5;
  8. std::string filename = "file" + std::to_string(a) + ".txt";
  9.  
  10. std::cout << "The filename is: " << filename << std::endl;
  11.  
  12. // if you need a const char*:
  13. const char* ptr = filename.c_str();
  14. std::cout << "As a pointer: " << ptr << std::endl;
  15. }
  16.  
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
The filename is: file5.txt
As a pointer:  file5.txt