954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

nested if, else

When I run the code, it works till the part where it asks about the dog's bredd, I press enter and it asks me about the dog's name, that's not supposed to appear. And also, when I enter the weight and press enter nothing happen, it's supposed to give me an answer but I don't know what's going on!, help me please!
thanks

cout<<"First Name and Last Name: "<>gotDog;

if(gotDog){
cout<<"What is the dog's breed?: "<= "30"){
cout<<"You are not welcome to the condominium!"<

sebassn
Newbie Poster
22 posts since Oct 2009
Reputation Points: 9
Solved Threads: 0
 

Why don't you write that for getting input from the user:

string breed;
cin >> breed;

This method does not get the "\n".

GDICommander
Posting Whiz in Training
211 posts since Jun 2008
Reputation Points: 72
Solved Threads: 26
 

Yes, be consistent with your input. Always use getline() and you shouldn't have to worry about cin.ignore()

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You