0

I`m a beginner in C++ so if someone could give me an example with very simple code this would be really appreciated.

I want to do this:

int main()
{
  function one();
  sleep 2000;
  system("start SOMETHING.exe");
  //when SOMETHING.exe closes
  function two();
  return 0;
}

Call a function, wait a 2 seconds for it to complete and change a few files. Start a exe file. And when the exe file closes it will call the second function. And finally close the exe I'm going to compile with the above code.

Can this be done with simple c++ code? How do I wait for Something.exe to close?

  • 1
    You really shouldn't be using `system`. To your question, you can use message passing between programs, wait for a file to be created and have `something.exe` create a file before close, check the task list to see if `something.exe` is still running, etc., etc.. – ChrisMM Jan 07 '20 at 16:03
  • That's not a very good dupe. The whole thread is about much heavier and more complex solutions to different problems. We can fix this with _one flag_... – Lightness Races in Orbit Jan 07 '20 at 16:10
  • https://stackoverflow.com/a/59632143/560648 – Lightness Races in Orbit Jan 07 '20 at 16:13

0 Answers0