我正在尝试从 matlab 调用一个“App.exe”文件(用 cpp 编写),该文件将视频名称(字符串)作为输入
我想使用执行操作系统命令并将结果返回给 Matlab 的函数“System”。
我在 Matlab 中写了以下内容:
system ('App.exe <' VideoName);
以及 Cpp 中的以下内容:
// to get the name of the video (the input) from the command.
std::string str;
getline(cin, str);
const char * name = str.c_str();
但是它不起作用。 所以我的问题是:我们如何通过输入从 matlab(甚至 cmd)调用“App.exe”。 我应该怎么做才能完成这项工作?
最佳答案
我不熟悉 matlab 语法,但您可能应该尝试将整个路径放入 App.exe。Matlab 的工作目录可能与 App.exe 所在的目录不同。或者,您可以将 App.exe 所在的目录添加到您的 PATH 环境变量中(并在执行此操作后重新启动 matlab 以确保它获得新值)。
关于c++ - 使用 "App.exe"命令从 Matlab 调用 (cpp) "System",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10400196/