i have a code that you enter section after section. when your done, you type end, and it stops asking you to enter in stuff. My problem is, I can get it to detect when I type end.
here is my problem:

cout << "\n\n\nTo start, enter each section line per line, by entering a section, hitting enter, then the next section, enter, and so on. when you done, type end.";
           cin >> stringa;
           end = stringc;
           if (end = end)
           {
                       cout<< "ok, you are now finished entering #'s\n\n";
                       }
                       else 
                       {           
                      cout << "\nNext:\n";
           cin >> stringb;
           end = stringc;
           if (end = end)
           {
                       cout<< "ok, you are now finished entering #'s\n\n";
                       }
                       else 
                       {           
                      cout << "\nNext:\n";
           cin >> stringc;
           end = stringc;
           if (end = end)
           {
                       cout<< "ok, you are now finished entering #'s\n\n";
                       }
                       else 
                       {           
                      cout << "\nNext:\n";
           cin >> stringd;
           }

I see the problem here. it's saying that if the string "end" equals itself, then go into the if statement. but what I want to happen is if someone actually types end, and hits enter, I want it to be able to know. if they type anything else, then just keep going. how do i do that?

Your IF statements are not testing for equality. You are assigning using just the single =.

Do this.

IF ( end == end )

blah, blah, blah

Is it a joke?
end == end is always true (if you don't overload operator ==, of course).
What's a sense of humor ;)...

if (stringa == "end")

I think that's what you meant.

thanks. the "" was what i was missing. I used the ==, but it didnt work, so thats why i didnt place that in the code i showed you guys.

thanks. the "" was what i was missing. I used the ==, but it didnt work, so thats why i didnt place that in the code i showed you guys.

So basically, you where properly comparing an arbitrary word against itself?

This article has been dead for over six months. Start a new discussion instead.