How to properly use system() to execute a command in C++?
I am new to C++ programming under Windows. I am trying to execute a command say cuobjdump
in C++ code using the system()
function:
system("C:program filesnvidia gpu computing...cuobjdump.exe --dump-cubin C:..input.exe");
output:
Usage : cuobjdump [options] <file>
This followed by the list of the options for cuobjdump.
When I execute this program I always get the cuobjdump help options displayed in the command line. It's as if the system call does not parse the filename. What am I doing wrong? I get the same result while using createprocess. The options --dump-cubin
gives an error as if I mistyped it.
试一试(也就是说,围绕着cuobjdump.exe路径"
,在C ++中正确转义为"
):
system(""C:program filesnvidia gpu computing...cuobjdump.exe" --dump-cubin C:..input.exe");
system("cuobjdump --dump-cubin pathfilename.exe");
那f
被编译器解释为一个字符串转义序列,请尝试pathfilename.exe
最明显的是, 是C / C ++字符串中的一个转义字符,所以如果你想直接使用它,它必须加倍。
system("cuobjdump --dump-cubin pathfilename.exe");
链接地址: http://www.djcxy.com/p/74850.html