cin.get() being ignored
Im using a switch case for menu options.In case 1 im just printing the values of a couple varibles.I put in the getline() but it seems to be by passed all together.
the varible flashs up on the screen as it should with out the getline().
if i use system("pause") within the switch case it stops the screen so i can make sure the vars are returning the correct values.Also if i put the getline() outside the switch case...
..i know the problem aint exactly the end of the world just curious whats not adding up,
playerStats( playerName, gold, playerTea ,playerFood,playerSpices, playerLoc);//just cout's stats
cout<<"YoU bRoKe ThE CoMpUtEr!!!"<<endl;
If getline doesn't wait for you to type something that means it's consuming stray input.
If you handle your input like this
std::cin >> foo;
it should fix the immediate problem. It's a better idea not to mix the getline function with stream extraction though, since they behave differently (getline reads anything, extraction skips over white space by default). If you can avoid that, do so.
thanks,I get you,its working now