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
CodePudding user response:
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.
CodePudding user response:
system("echo "a" ");
the operator a
is unknow.
You can passe an argument with "
only if you add \
.
Exemples :
system("echo \"a\" ");
system("echo \"a\" \"a second argument with spaces\"");