Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何通过命令行以编程方式运行程序并获取其返回值?我希望有一种适用于 Windows 7 和 MacOS X 的方法,但如果我需要对每个操作系统进行不同的编程,我也会这样做
您可以使用system调用程序并检索其返回值。
一个例子是
int returnValue = system("C:\\SomeProgram.exe");