key word break wont break out of the loop

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
do
		{
			cout << endl;
			cout << "Enter Your Blend Key from -11 to 10" << endl;

			beta = 1.0;
			cout << endl;
			cin >> alpha;
			if ((double)alpha >= (-11.0) && (double)alpha <= 10.1)
			{
				addWeighted(img, alpha, img2, beta - alpha, 0, des);
				imshow("img", img), waitKey(0);
				imshow("ime1", img2), waitKey(0);
				imshow("Blended", des), waitKey(0);
				 break;
			}
			else
			{
				cout << "Wrong Entry";
			}
		} while (true, cout << " Try Again!!!" <<endl);
		
		do
		{
			cout << "Enter Key" << endl;
			char  key = cv::waitKey(0);
			cin >> key;
			if (key == 'Q' || key =='q' || key == 'E' || key =='e' )
			{
				EXIT_SUCCESS;
			}
		} while (true, cout<<"Enter 'Q' or 'E' To Quit"<<endl);
		



i want to break out of this do-while loop but, i wont just get out of the loop,
but when i change the waitkey argument to 1 it breaks but the other codes does not run... any help pls
Last edited on
Was it too much trouble to post the 'do' part as well?

Also, what's with all the abuse of the comma operator?
have updated the code
Because you're using the comma operator,
while (true, cout << " Try Again!!!" <<endl);
is equivalent to
while (cout << " Try Again!!!" <<endl);

imshow("img", img), waitKey(0);
is equivalent to
1
2
imshow("img", img);
waitKey(0);

(somebody correct me if I am wrong on this last one because this is just my assumption).

Just wanted to point that out.

If your problem is that you're stuck at waitKey(0), then that has nothing to do with the do-while loop.
If you want us to help you then you need to give us more details as to what those functions do, what you're expecting, what you're getting, what you want.
the function accepts two input, then apply the addweighted function to the image and display the result, the first image, the second and the result of the two image, the waitkey is suppose to wait till any key is pressed and then it display the other one, which works well, but the last waitkey(0), is suppose to help execute the below code but it is not doing that
I'm wondering what line 30 is all about
EXIT_SUCCESS;
You really, really ought to read up on what the comma operator actually does in C++. Your use of it on lines 12 - 14, 21 and 32 makes no sense.
Topic archived. No new replies allowed.