473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

simple while loop in c++

Hi there

I am writing a simple while loop which terminates on the condition that a certain value is found, as follows


Expand|Select|Wrap|Line Numbers
  1. std::string question = q.quest().que();
  2.             std::string answer = q.ans().answer();
  3.             std::string graphic = q.inf().info();
  4.             std::string english1;
  5.             std::string english2;
  6.             std::string arabic1;
  7.             std::string arabic2;
  8.  
  9.  
  10.             while((answer != english1) || (answer != english2)) { 
  11.                        random_shuffle(opt.begin(),opt.end()); 
  12.                             english1 = opt[0].english();
  13.                             arabic1 = opt[0].arabic();
  14.                             english2 = opt[1].english();
  15.                             arabic2 = opt[1].arabic();
  16.             }

The program gets stuck in the while loop. I guess this is some sort of error in the while loops condition. If I take out the second condition and make it just based upon “English1”, then it works fine.

Any help?

Thanks in advance
Feb 1 '08 #1
1 1649
JosAH
11,448 Expert 8TB
Suppose your answer equals english1; does it equal english2 as well then?

kind regards,

Jos
Feb 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Arthur J. O'Dwyer | last post by:
I was paging through Coplien's book "Advanced C++ Programming Styles and Idioms" this afternoon and found some code that looked something like void sort(vector<foo> a) { int flip; do { for...
22
by: lokman | last post by:
Hi, In the following code, can someone tell me the difference between *p++ and p++ ? I can see both achieve the same result. Thanks a lot !
1
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to...
14
by: dba_222 | last post by:
Dear experts, Again, sorry to bother you again with such a seemingly dumb question, but I'm having some really mysterious results here. ie. Create procedure the_test As
6
by: porky008 | last post by:
I need to modify the following program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the...
23
by: AndersWang | last post by:
Hi, dose anybody here explain to me why memset would be faster than a simple loop. I doubt about it! In an int array scenario: int array; for(int i=0;i<10;i++) //ten loops
0
by: rich | last post by:
Hi all, I have a fairly complex "feed" application that recieves messages from an external user-supplied API via a callback function, and attempts to forward these messages to another...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
1
by: Jon Slaughter | last post by:
Say I have two nested foreach loops, is there any simple way of continuing out of the outter most loop depending on what happens in the inner most? e.g., foreach(int i in I) { foreach(int j...
1
by: jerry | last post by:
i have written a simple phonebook program,i'll show you some of the codes,the program's head file is member.h . i suppose the head file works well.so i don't post it. here's the clips of main...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.