3 Replies - 484 Views - Last Post: 24 February 2009 - 08:21 PM Rate Topic: -----

#1 luckyman76  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 05-February 09

help with do/while loop...

Posted 24 February 2009 - 08:06 PM

I need help with this do/while loop...the only way I can get out of it (if the user chooses x to quit) is to use: exit(0);

The problem is...I just want out of the loop because there are other things within the code that need to be executed...what could be another action I could put to get out of the loop?



Here's the loop:
   do { 
   cout << "\n(X) to quit" << endl;
	 cout << "(L)ighten, (D)arken, (S)harpen, (B)lur or S(p)ecial Effect:";
	 cin >> ch;

   if (ch == 'L' || ch == 'l') {
	 cout << "How much";
	 cin >> changeAmt;
	 myimage.lighten(changeAmt);
   }	  

   if (ch == 'D' || ch == 'd') {
	 cout << "How much";
	 cin >> changeAmt;
	 myimage.darken(changeAmt);
   }

   if (ch == 'S' || ch == 's')
	 myimage.sharpen();

   if (ch == 'B' || ch == 'b')
	 myimage.blur();

   if (ch == 'P' || ch == 'p')
	 myimage.checkers();
  
   if (ch == 'X' || ch == 'x')
	 exit(0);			//What can I put here to just exit the loop?
   }  while (ch != 'X' || ch != 'x');


Is This A Good Question/Topic? 0
  • +

Replies To: help with do/while loop...

#2 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: help with do/while loop...

Posted 24 February 2009 - 08:11 PM

break;




Hope this helps!
Was This Post Helpful? 1
  • +
  • -

#3 luckyman76  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 05-February 09

Re: help with do/while loop...

Posted 24 February 2009 - 08:19 PM

It worked! you're the man...
:^:

View Postpr4y, on 24 Feb, 2009 - 07:11 PM, said:

break;




Hope this helps!

Was This Post Helpful? 0
  • +
  • -

#4 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: help with do/while loop...

Posted 24 February 2009 - 08:21 PM

Sometimes the simple things in coding are the hardest to figure out! It's like the age old saying, "You can't see the forest because of the trees."

^ Applies in this situation :)


Glad I could be of assistance!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1