C++ doesn't run my MENU?

Hey CPlusPlus Community,

I'm back with another question.
When I run the folowing code (which isn't by far finished!) it doesn't show my menu but immediately stops.

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
#include "stdafx.h"
#include <iostream>
using namespace std;
void mainMenu();
bool stop = false;

int main()
{

	if (stop=false)
	{
		mainMenu();
	}

	return 0;

}

void mainMenu()
{
	int answer;
	cout << "Do you want to:\n1: Draw a square?\n2: Do simple calculations?\n3: Draw a line?\n4: Exit\nGive a number:\n";
	cin >> answer;
	switch(answer)
	{	

	case 4:
		stop = true;
		break;
	default:
		mainMenu();
		break;
	}
}


NOTE: it isn't finished yet, but I don't think that has anything to do with the not showing the menu.
Can someone please tell, or hint, me what I'm doing wrong? ;-)

Thanks in advance,

-Delpee
Last edited on
in C++ operator '=' is an assignment operator and what you need here is equality operator '=='
correct line 10
for more info read here:
http://cplusplus.com/doc/tutorial/operators/
Ofcourse! :O
Thanks John, I realy overlooked that, well, I guess that's where you're a beginner for ;-).
I appreciate the quick respons!
Writing stop == false is the same as writing !stop, by the way (! is logical not), so you could also just write
if (!stop) // etc because they both just evaluate to true or false. if (stop), if (!stop), if (true), if (false) are all synatactically correct.
Last edited on
Yeah, I knew that. I just find 'stop==false' clearer then '!stop'. But that's just me.
Last edited on
hahaaa I didn't even see it... It gave me ideas though.
Last edited on
Topic archived. No new replies allowed.