Archived

This topic is now archived and is closed to further replies.

phil05

Getting Input (y/n) instead of (1/0)

Recommended Posts

I realized it''s a bit trickier. Can you give me a code example so the user can type in "y" or "n"?

char TEMP_PASSWORD[7];
char PASSWORD[] = "natale";
int choice;	

std::cout << "Enter Your Password: ";
std::cin >> TEMP_PASSWORD;

if (strcmp(PASSWORD, TEMP_PASSWORD)) 
{
	std::cout << "\nYou have entered an invalid password. Please contact Phillip Vaira ";
	std::cout << "at \nphil@webula.net if the problem persists." << std::endl;

	std::cout << "\nTry again? (1/0): ";
	std::cin >> choice;
		if (choice == 1)
	        {
			main();
		}
		if (choice == 0)
		{
			exit(1);
		}
}
 

Share this post


Link to post
Share on other sites