Reputation: 47
have a problem with system("command")
.
I want to start .exe with some parameters but "B0 P1"
cant be compiled because of use ""
in command string. Any solution/tips :)?
int main() {
system ("start C:\\PROGRA~2\\BEL\\Realterm\\realterm.exe FIRST=1 SENDSTR= "B0 P3" ");
}
Upvotes: 0
Views: 72
Reputation: 2786
You need to escape quote characters inside your string:
int main() {
system ("start C:\\PROGRA~2\\BEL\\Realterm\\realterm.exe FIRST=1 SENDSTR= \"B0 P3\" ");
}
In c++ 11 you can also use string literal R"(...)" if you don't want to escape characters:
int main() {
system ( R"(start C:\PROGRA~2\BEL\Realterm\realterm.exe FIRST=1 SENDSTR= "B0 P3")" );
}
Upvotes: 3