-1

I've got a compiled executable file called "starTracking", and I need to use another c++ program to run this file. Right now I'm using:

system("./starTracking");

But I can't wait it to finish before calling it again, so I'd like it to run apart from my main program so I can call it several times without making my main program wait. Could someone tell me if there's a way to do it? I'd be so grateful :D

  • 1
    and [this question](https://stackoverflow.com/questions/5237482/how-do-i-execute-external-program-within-c-code-in-linux-with-arguments) for linux. – Xiobiq Aug 18 '16 at 02:45

1 Answers1

0

I need to use another c++ program to run this file

If running your C++ on Windows read up on this guide Creating Processes.

I can't wait it to finish before calling it again, so I'd like it to run apart from my main program so I can call it several times without making my main program wait.

That's what running a process will do. To send/receive data to and from the external program make sure you involve stdin and stdout. See this section of the guide: Creating a Child Process with Redirected Input and Output.

  • `You must be running your C++ on either a Windows or Unix system` Why you'd think so? – dxiv Aug 18 '16 at 06:36
  • Last time I checked I had to involve `Windows.h` to use `createProcess`. It is a Win32 API, isnt it? –  Aug 18 '16 at 06:52
  • It is, of course. But where in OP's question was `CreateProcess` even mentioned? – dxiv Aug 18 '16 at 06:56
  • If OP knew about `CreateProcess` then their question wouldn't exist to need such a suggestion (as told in my answer). Think about it. Also, read their last paragraph again, doesn't it sound like `CreateProcess` is right? If I too was tracking stars I might want to query the running tool (process) with std in/out for regular feedback into my own code... –  Aug 18 '16 at 08:09