#include <cstdlib> #include <iostream> #include <sys/wait.h> int main() { int result = std::system("ls -l"); // 调用ls命令列出当前目录内容 if (result == -1) { std::cerr << "Failed to execute command" << std::endl; } else { if (WIFE...
// execute the UNIX command "ls -l >test.txt" std::cout << std::ifstream("test.txt").rdbuf(); #endif } CMakeLists.txt cmake_minimum_required(VERSION 3.15) project ( test ) set ( PRJ_COMPILE_FEATURES ) set ( PRJ_COMPILE_DEFINITIONS ) list ( APPEND PRJ_COMPILE_FEATURES cxx_...