Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Password Check

DZone's Guide to

Password Check

·
Free Resource
// description of your code here


#include 
  
   
#include 
   
    
using namespace std;

void main()
{
	int counter = 0;
    string pw;
	string default_pw = "1234"; //預設密碼 

	while(true)
	{
		cout<<"Enter your password:";
		cin>>pw;

		if(pw.compare(default_pw) == 0)
		{
			cout<<"驗證通過";
			break;
		}else if(++counter == 3)
		{
			cout<<"驗證失敗";
			break;
		}
	}
	
	cout<
    
   
  
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}