3
this answerで説明したように、私はWindowsコマンドを実行し、Visual StudioプロジェクトでC++内の出力を取得しようとしました。コマンドを実行して出力を取得する:popenとpclose undefined
std::string executeCommand (const char* cmd) {
char buffer[128];
std::string result = "";
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
if (!pipe) throw std::runtime_error("popen() failed!");
while (!feof(pipe.get())) {
if (fgets(buffer, 128, pipe.get()) != NULL)
result += buffer;
}
return result;
}
問題は、これがcompiling.The次のエラーが与えられていない、次のとおりです。
Error: identifier "popen" is undefined.
Error: identifier "pclose" is undefined.
はいくつかの標準的なされていないことを回避したファイルが含まれていますか? –