I made a code that had a y/n option in it. I was wondering why after I press 'n', instead of displaying
Enter name: (waits for person to input value for Name)
Enter class: (waits for person to input value for Class)
Enter attack: (waits for person to input value for atk)
Enter defense: (waits for person to input value for def)
which it did in main, it displays
Enter name: Enter class: (waits for person to input value for Class)
Enter attack: (waits for person to input value for atk)
Enter defense: (waits for person to input value for def)
instead.
It still displays the previous value of "Name" the second time around. It didn't give the person a chance to input a new value for Name, skipping to Class instead. And it prints "Enter name: Enter class" on the same line, even though I did not use \n or endl. Any suggestions?
You shouldn't mix getline and cin. getline by default reads until a newline is found('\n') and cin leaves a newline in the buffer. To fix this, you are going to want to ignore anything left in the buffer from cin. with std::cin.ignorehttp://www.cplusplus.com/reference/istream/istream/ignore/?kw=cin.ignore
Another thing to mention for your editInfo function you should be passing by reference(&) if you wish to modify the variables. By the way why are you streaming to the "guildmember" object. You should read directly into the guildmember object.