cmd창에서만 실행할 수 있는 명령어를 C++ 스크립트에서 실행하는 코드이다. 생각보다 간단하다.
#include #include #include "main.h" std::string exec(const char* cmd) { std::array
; } while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { result += buffer.data(); } return result; } 위 함수를 이용하면 된다.
함수에 인자로 명령어를 넘겨주고 출력하면 끝이다. 예를들면 아래와 같다. int...
#
c
#
cmd
#
명령어
#
컴파일
#
콘솔
원문 링크 : C++ 콘솔 실행 명령어, 다른 cpp 컴파일