C++ 在c+中运行shell脚本+;

C++ 在c+中运行shell脚本+;,c++,C++,我一直在写以下代码: #include <iostream> #include <stdlib.h> using namespace std; int main() { cout << "The script will be executed"; system("./simple.sh"); } #包括 #包括 使用名称空间std; int main(){ cout刷新输出流缓冲区应该足够了。您可以使用 cout <&l

我一直在写以下代码:

#include <iostream>  
#include <stdlib.h> 
using namespace std; 
  int main() {  
  cout << "The script will be executed"; 
  system("./simple.sh");  
} 
#包括
#包括
使用名称空间std;
int main(){

cout刷新输出流缓冲区应该足够了。您可以使用

cout << "The script will be executed";
cout.flush();

您可以使用
cerr在调用system()系统调用之前尝试刷新标准输出流。

您没有刷新输出流

尝试:

cout
cout << "The script will be executed" << endl;
cout << "The script will be executed" << endl; // or cout.flush()
system("./simple.sh");