HI I have a question to ask. I wrote this program to check if a user imput "Hello World" correctly, but when I tested it out, correct input is also marked as wrong. Can someone help me with this? Code: #include <iostream> #include <string> using namespace std; int main() { string s; cin >>\ s; getline (cin, s); if (s == "Hello World"){ cout << "OK"; } else { cout << "Wrong Answer"; } }
I tried that, but the program still doesn't run correctly. When I enter Hello World, it outputs wrong answer
simply use cin>> s; no need to use getline if you are taking string as a datatype and take care that C++ is case sensitive so in input, it should be Hello World only