Jump to content
  • Advertisement
Sign in to follow this  
TheOne1

Something wrong wit cin

This topic is 5136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

void createChar( PlClient &setObj )
{
	char setName[ 20 ];
	cout << "Character creation process\n\n";

	cout << "Enter name for character (20 Characters max): ";
	cin.getline( setName, 19 );
	cout << '\n';


	cout << setObj.getName();

	system("pause");
	system("cls");
}

// the function above is accessed through this swith/case menu
while ( menu ) {
		cout << " Character Creation Process\n"
			 << " 1. Create Character\n"
			 << " 2. View Character\n"
			 << " 3. Finish Character\n"
			 << " 4. Back\n\n";

		cout << "Enter # choice: ";
		cin >> menuChoice;

		switch ( menuChoice ) {

		case CREATEC:
			system("cls");
			createChar( tempObj );
			break;
                  ...
                  ....

I don't know what is wrong. When createChar( PlClient &setObj ) is entered, it doesn't let wait for user input. When it enters the function, it prints out: Character Creation Process Enter name for character (20 Characters max): =Press any key to continue... Funny thing is that I don't know why that = sign is printed. I'm guessing that something "is left in the input buffer," which I have been told many times, but I have no idea what that means, or how something has been left in the input buffer. To access the function, you need to enter "1"(through a switch/case menu). Any suggestions? Oh, and please don't tell me it's a bug in MSVC++6.0. I've been told that, fixed it, and nothing changes!

Share this post


Link to post
Share on other sites
Advertisement
Ok, so the problem is that a newline seems to be in the input buffer. How do I clear it? cin.clear() only clears failed cin inputs...so how do I clear the input buffer?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!