How to make multiple infinite loops at once?

1
2
3
4
5
for(;;)
CopyFile(
    "c:\where\I\want\it\myapp.exe",
    "c:\where\I\want\it\myapp.exe",
sleep(60000);

1
2
3
4
5
for(;;)
CopyFile(
    "c:\where\I\want\it\myapp.exe",
    "c:\where\I\want\it\myapp.exe",
sleep(70000);
These are 2 codes I want to get work in app at once independently. Can I achieve this?
Last edited on
I don't follow. You want to copy a file onto itself continuously in two different threads? What's the point?
I was just looking for principle, but I figured this out
Last edited on
Idk if I'm understanding you correctly but If you're wanting an infinite loop, I always use while statements and trap myself inside

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using namespace std;

int main ()
{
char controls;

cout << "Run Programs?(Y/N)" << endl;
while (true)
{
    cout << "C://> ";
    cin >> controls;
    controls = touppper(controls);
    if (controls == 'Y')
    {
        break; //gets you out of infinite loop
    }
    if (controls == 'N')
    {
        //doesn't run programs, shuts down
         return 0;
    }
    if (controls != 'Y' && controls != 'N')
    {
        cout << "\n";
        //loops to beginning
        continue; 
    }

cout << "Out of loop by choosing \"Y\"." << endl;
return 0;
}
Topic archived. No new replies allowed.