I need some help comparing 2 strings
so if in a file there is the string ex: "hello world" and them the user inputs a string I need the program to tell me if the 2 strings are the same (are they both hello world)
string equality is an exact binary match. That means case matters, spaces matter, and so on.
"hello" != "Hello" in c++.
" hello" != "hello" in c++.
the best way to see what is going wrong if the data "looks the same when I write it with cout" is to print the actual hex bytes of both strings to the console and compare that by hand. You will see why they are not equal when you do that, and can then back track how it got that way and what to do about it.
Ripb, you're using two slightly different methods to get input.
Your file is using getline, but your user input is using cin operator>>.
operator>> when used with streams is whitespace-delimited, so it's only storing the first word (hello).
Use getline for both places if you need to keep the whitespace.