1. 首页
  2. 数据库
  3. 其它
  4. linux c++ 调用shell命令保存执行结果 示例

linux c++ 调用shell命令保存执行结果 示例

上传者: 2021-01-16 17:14:42上传 PDF文件 22.49KB 热度 18次
下面的代码用于在c++函数里面调用shell,并且执行命令,取回命令执行结果。 #include #include #include #include int main() { const int SIZE = 64; const int MAX_RESPONSE_SIZE = 65535; char charBuff[SIZE]; int bytesRead = 0; int closeResult; std::string result_; std::string cmd_ = ls -al; // 要执行的命令 if
下载地址
用户评论