So that sounds very simple, but I get weird behavior.
My program has the following code:
std::cout << "Would you like to generate a complexity graph or calculate global complexity? (graph/global)\n";
char ans[6];
std::cin >> ans;
if (ans != "global") std::cout << ">>" << ans << "<<" << std::endl;
When I run my program and type "global", when I am prompted to enter it, the program returns:
>>global<<
Why is the if statement evaluated as true?
source
share