Ask coding questions

← Back to all posts
Having issues with comparison of a variable to a string
tickedoffsquid (16)

This happens in the class choosing area, even if I choose "rogue" or anything, it says I haven't, kinda confused, thanks in advance

Answered by Coder100 (17045) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (17045)

std::cin is a bit buggy at some times. It won't match spaces, and is generally really really weird.

You should use getline:

std::string name;
std::getline(std::cin, name);

if (name == "....") ...

if (choice == "3") ...