Whitespace is not significant to the compiler. Just because all those lines after EditMenu==1 are indented, doesn't mean they are actually part of the if-statement, so std::cin >> AddItem will always happen. (You only get one statement in an if, although you can make it a block if you want.)