-1

I need using an int veriable in system() function for my c++ program. for example:

  • int a = 0;
  • system("echo "a" ");

but i get an error and i need help about how i use this like that Error: C++ user-defined literal operator not found

Lukas-T
  • 11,133
  • 3
  • 20
  • 30

1 Answers1

5

That's never going to work. C++ doesn't plug integers into strings that way. Instead, you can do:

int a = 42;
std::string s = "echo " + std::to_string (a);
system (s.c_str ());

Also, you might consult this page, in order to learn the language properly.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48