0
#include"bits/stdc++.h"
using namespace std;
int main() 
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int x = 1;
    while (x < 100) {
        cout << x;
    }
    return 0;
}

Which flag or script should I add in Command Prompt while running this program such that it kills the process after some time(say 1 second) and doesn't hang my computer ?Actually I want to make a sublime-build that kills the process say after t seconds but the timeout in windows is used for waiting unlike the timeout in linux.

yadav_gaurav
  • 15
  • 1
  • 6
  • 1
    Does this answer your question? [How to set a timeout for a process under Windows 7?](https://stackoverflow.com/questions/13515254/how-to-set-a-timeout-for-a-process-under-windows-7) – SuperStormer Feb 16 '21 at 02:24
  • No I tried this but the program doesnt't stops – yadav_gaurav Feb 16 '21 at 02:28
  • Also Should I ask another question because this one got associated with that question ?I am new to Stack-Overflow . – yadav_gaurav Feb 16 '21 at 02:31
  • In an async thread use Sleep(milliseconds); to pause a program, and exit(3); to terminate it – Lightning Gaming Feb 16 '21 at 02:41
  • @LightningGaming should I write myprogram.exe exit(3) ? Also what is 3 here ? – yadav_gaurav Feb 16 '21 at 02:52
  • If you're this new to C++, you shouldnt be learning bad practices from competitive programming(`#include "bits/stdc++.h"` and `using namespace std;` are both bad) and should first follow an actual C++ tutorial. – SuperStormer Feb 16 '21 at 02:57
  • See [Why is `using namespace std` considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) and [Why should I not `#include `?](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) for details... – MattDMo Feb 16 '21 at 19:02

0 Answers0