I have to end a program in a void...

I have a void that needs to end a program but a break and return 0 both won't work. Instead I have it cout (1/0). It works but is there an alternative?

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <thread>
#include <Windows.h>
#include <limits>
using namespace std;
double clicks=0;
double result;
bool gameon=false;
char inpot;
bool wait=false;
void keyget(){
for(;;){
if ( GetAsyncKeyState ( VK_LBUTTON ) & SHRT_MAX && gameon==true){
clicks++;
}
else{
}
}
}
void other(){

for(;;){
    cout <<"Starting game in 5..."<<endl;
    Sleep(999);
    cout <<"Starting game in 4..."<<endl;
    Sleep(999);
    cout <<"Starting game in 3..."<<endl;
    Sleep(999);
    cout <<"Starting game in 2..."<<endl;
    Sleep(999);
    cout <<"Starting game in 1..."<<endl;
    Sleep(999);
    gameon=true;
    clicks=0;
    cout <<"CLICK!"<<endl;
    Sleep(9999);
    cout <<"Time's up!"<<endl;
    gameon=false;
    result=clicks/10;
    cout <<"You got "<<clicks<<" clicks in 10 seconds. That's "<<result<<" clicks per second!"<<endl;
    cout <<""<<endl;
    cout <<"If you want to go again, type y and press enter."<<endl;
    cin >>inpot;
    if(inpot=='y'){
    cout <<"Get ready to go again..."<<endl;
    cout <<""<<endl;
    }
    else{
        cout <<"Exiting. But first.."<<endl;
        cout <<"One divided by zero is.."<<endl;
        Sleep(1700);
        cout <<"It is uh.."<<endl;
        cout <<"OH! I'VE GOT IT! IT IS.."<<endl;
        Sleep(2300);
        cout <<(1/0)<<endl;//this is where i want a return 0 equivalent.
    }

}
}
int main(){
cout <<"You have 10 seconds to click as many times as possible."<<endl;
thread one(keyget);
thread two(other);
one.join();
two.join();
return 0;
}
Just use:
 
return;
thanks for the help!
And in this case, break; can be used too.
Topic archived. No new replies allowed.