473,387 Members | 1,575 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,387 software developers and data experts.

wierd 'bool

134 100+
when i run this 'bool'...
if i press 1, 2, or even 3....
it will say



"What would you like to do?
1. Sleep
3. Leave
You Rest
(Then runs function level up)"

then i press 1,2, or 3...
it will say the same thing



Expand|Select|Wrap|Line Numbers
  1. bool RentRoom()
  2. {
  3.      cout<<"What would you like to do?\n";
  4.      cout<<"1. Sleep\n";
  5.      cout<<"2. Leave\n";
  6.      int InnOption3;
  7.      cin >> InnOption3;  
  8.      cin.ignore(20,'\n');
  9.      //Problem Here
  10.      if (InnOption3 = 1)
  11.         {
  12.         cout<<"You Rest\n";
  13.         LevelUp();
  14.         RentRoomtoRentRoom();
  15.         }
  16.      if (InnOption3 = 2)
  17.         {
  18.         cout<<"You leave the Inn and enter Imperial City\n";
  19.         cin.get();
  20.         ImperialCityOptions();
  21.         }
  22. }
  23. bool RentRoomtoRentRoom()
  24. {
  25.  RentRoom();    
  26. }
  27.  
Apr 29 '07 #1
2 1037
ilikepython
844 Expert 512MB
when i run this 'bool'...
if i press 1, 2, or even 3....
it will say



"What would you like to do?
1. Sleep
3. Leave
You Rest
(Then runs function level up)"

then i press 1,2, or 3...
it will say the same thing



Expand|Select|Wrap|Line Numbers
  1. bool RentRoom()
  2. {
  3.      cout<<"What would you like to do?\n";
  4.      cout<<"1. Sleep\n";
  5.      cout<<"2. Leave\n";
  6.      int InnOption3;
  7.      cin >> InnOption3;  
  8.      cin.ignore(20,'\n');
  9.      //Problem Here
  10.      if (InnOption3 = 1)
  11.         {
  12.         cout<<"You Rest\n";
  13.         LevelUp();
  14.         RentRoomtoRentRoom();
  15.         }
  16.      if (InnOption3 = 2)
  17.         {
  18.         cout<<"You leave the Inn and enter Imperial City\n";
  19.         cin.get();
  20.         ImperialCityOptions();
  21.         }
  22. }
  23. bool RentRoomtoRentRoom()
  24. {
  25.  RentRoom();    
  26. }
  27.  
The problem is that you have:
Expand|Select|Wrap|Line Numbers
  1. if (InnOption3 = 2){}
  2.  
which should be:
Expand|Select|Wrap|Line Numbers
  1. if (InnOption3 == 2){}
  2.  
Remeber the "==" sign checks for equality. The "=" sign assigns to something.
Apr 29 '07 #2
lumpybanana247
134 100+
The problem is that you have:
Expand|Select|Wrap|Line Numbers
  1. if (InnOption3 = 2){}
  2.  
which should be:
Expand|Select|Wrap|Line Numbers
  1. if (InnOption3 == 2){}
  2.  
Remeber the "==" sign checks for equality. The "=" sign assigns to something.
worked like always
Apr 29 '07 #3

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

Similar topics

3
by: Markus Fischer | last post by:
Hi, I'm experiencing a wierd problem with IE 6 in Windows with two _slightly_ different Version. Give the following HTMl-Code, ideally the output of offsetTop should be "105"; a few pixel...
3
by: Sathyaish | last post by:
A practice excercise from K&R. Kindly read the comments within the program. I'd be very grateful to people who helped. Why is it that I get the wierd face-like characters on the screen instead of...
3
by: B Vidyadhar Joshi | last post by:
I was writing an Bluetooth Application which makes calls to Windows APIs. I feel I'm doing something wrong with the structure. Could somebody help me? The code that I'm using is pasted below: ...
0
by: Michael | last post by:
Hi, I found a wierd problem in DataGrid. If I set DataGrid's DataSource to empDataSet1 at designtime, then I can never change its DataSource at runtime, e.g., in the Button1_Click event...
0
by: Tom | last post by:
OK, here's a wierd one... I have a listbox, which I fill with strings (in my case, file names). I normally load this via a loop, adding each item to the list box in the loop. I put lb.BeginUpdate...
0
by: Navin Mishra | last post by:
Hi, I've a service that connects to the clients via TCP and sends data on client's opened TCP port. The data is in XML and I use ASCII encoding. There is 8 byte of header containing length of...
3
by: Tom | last post by:
We are experiencing some wierd debugging behavior. What happens is that, during debugging with VS 2003, the debugger seems to 'skip' statements that are associated with database operations. For...
3
by: markb | last post by:
Hi My C# app is being called from a callback from an unmanaged DLL. One of the parameters of the callback is of type BOOL. I am using PInvoke to marshal this to a (managed) bool. The problem is...
5
by: desktop | last post by:
I am confused about the use of the template parameter "E" in the below class. Since when is it allowed to use these parameters like "E(1)" and what does it mean (where can I read more about this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.