Ive been writing the folowing code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
cout << "The script will be executed";
system("./simple.sh");
}
But when I run it the shell script is executed first.
What can I do to execute “cout << “The script will be executed”” first?
Flushing the output stream buffer should be enough. You can do this with
Alternatively, if you intended to also print a newline character then you can use
std::endlwhich implicitly flushes the buffer: