However, even if I enter "Hello World!", nothing happens! It appears to be working fine with cin, but I want multiple lines of input. So why isn't this comparision working?
Sorry, bad code. I meant to compare the user input to "Hello World!".
Regardless of the input, my original question is why the string comparisons doesn't work with getline. If I used cin instead, things work, but I want my input to contain a space, so I have to use getline.
Dude, we seriously need more information -- unless you are only here to hate on C++.
OS? Version?
Compiler? Version? Compile command? Flags? Etc.
Got multiple compilers in your PATH?
No warnings? Messages of any kind?
Anything else linked to your code, or in your code, that you aren't sharing?
Be cause you are claiming that valid code isn't, a priori -- code that is correct and should flawlessly function for compilers 20 years old.
In other words, something on your end is screwed up, not in the language, or the compiler design, or our understanding of the presented material, or anything...
^^^ Print the string letter by letter in hex, and also its length, for both strings, one on top of the other. It will pop out if there is a char encoding issue.
Sometimes the same looking letter isnt really the same. If you put a 0 instead of space between 2 words, it will look like a space in a std::string on most consoles. If you use windows' quotes instead of quote char, those do not match, as anyone who ever opened and resaved code in M$ word or M$ outlook knows. And there are local settings that move a few things around as well. Do the above and show us the output or see if that is your issue.