Sign in to follow this  

Something wrong wit cin

This topic is 4862 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
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

This topic is 4862 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this