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: "<<endl;
    getline(cin,naME);


    cout<<"Do you own a dog at the present time? Type 1 for YES or 0 for NO: "<<endl;
    cin>>gotDog;

    if(gotDog){
        cout<<"What is the dog's breed?: "<<endl;
        cin.ignore(200, '\n');
        getline(cin,brEEd);

        if(brEEd == "pit-bull"){
            cout<<"You are not welcome to the condominium!"<<endl;
            cout<<"It's illegal to have a pit-bull in South Florida."<<endl;

        }else{
            cout<<"How much does it weight?: "<<endl; 
            cin.ignore(200, '\n');
            getline(cin,lbs);
        }

            if(lbs >= "30"){
                cout<<"You are not welcome to the condominium!"<<endl;
                cout<<"It's prohibited to have dogs that weights more then 30 lbs."<<endl;
            }else{
                cout<<"What is the dog's name? "<<endl;
                cin.ignore(200, '\n');
                getline(cin,dogNm);
            }
    }else{
        cout<<"You are welcome to the condominium!"<<endl;
    }

Recommended Answers

All 2 Replies

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

string breed;
cin >> breed;

This method does not get the "\n".

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.