Challenge

I challenge you all to compile these 2 Projects (place them in the same directory)and then click on either one. After that try and terminate both of the process and post up here how you did it. WITHOUT SHUTINGDOWN/RESTARTING YOUR COMPUTER (or deleting the actual file) but you can use any other Programs that you have made.


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
#include <Windows.h> 
#include <WinUser.h>
#include <iostream>

using namespace std; 


HWND stealth;



int main() {

	system("title Project25");
	stealth = FindWindow(NULL, TEXT("Project26"));

	while (stealth != 0)  
	{
		stealth = FindWindow(NULL, TEXT("Project26"));

	}
	
	cout << "Project26 has been exited";
	system("start Project26.exe");
	main(); 
	 
	}





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
#include <Windows.h> 
#include <WinUser.h>
#include <iostream>

using namespace std;


HWND stealth;



int main() {

	system("title Project26");
	stealth = FindWindow(NULL, TEXT("Project25"));

	while (stealth != 0)
	{
		stealth = FindWindow(NULL, TEXT("Project25"));

	}

	cout << "Project25 has been exited";
	system("start Project25.exe");
	main();

}
Last edited on
Both of these code sets result in undefined behavior. You may not call main.
Learn how to use loops, DeathAngle:

1
2
3
4
while(true)
{
    // this code will repeat indefinitely
}



Functions are not gotos. Don't treat them that way.
Topic archived. No new replies allowed.