3 c
我想编写调用另一个exe的c程序.在我调用原始exec之前,这个包装器程序除了设置一些环境变量之外什么都不做.例如,假设我有一个被调用的exe test.exe,我写了testwrapper.exe
我想把它称为testwrapper.exe < parameter >,并在内部它应该调用test.exe < parameter >
我的问题是,当我打电话test.exe的test.exe "c:\program files\input",C与逃脱"作为传递参数
是什么导致了这个问题,我该怎么做才能修复它?
引号应该允许带空格的参数.例如:
test.exe "this is an argument with spaces"
Run Code Online (Sandbox Code Playgroud)
为了在参数中加上引号,请将它们转义:
test.exe "\"c:\program files\input\""
Run Code Online (Sandbox Code Playgroud)
如果你是在C程序中调用它,则必须双重转义引号.例如:
system("test.exe \"\\\"c:\\program files\\input\\\"\"");
Run Code Online (Sandbox Code Playgroud)
但是,查看运行的代码行会很有帮助test.exe.
| 归档时间: |
|
| 查看次数: |
2293 次 |
| 最近记录: |