#include"Header.h"
#include<stdio.h>//清屏頭檔案
#include<iostream>//C++頭檔案
#include<string.h>//字串頭檔案
using namespace std;
int main()
{
string ID,key;//進入程式所需賬號密碼
cout<<"pleace enter your username:";//管理員名
for(int i=0;i<3;i++)
{
cin>>ID;
if(ID!="admin")
{
cout<<"ID can't be found!"<<endl;
cout<<"pleace enter your username:";
if(i==2)exit(0);//三次錯誤跳出
}
else break;
}
cout<<"pleace enter your password:";//管理員密碼
for(i=0;i<3;i++)
{
cin>>key;
if(key!="admin")
{
cout<<"key is wrong!"<<endl;
cout<<"pleace enter your password:";
if(i==2)exit(0);//三次錯誤跳出
}
else break;
}
readdate();//——————————————————————讀取
hello();//歡迎界面
cout<<"按任意鍵回傳"<<endl;
system("pause");
return 0;
}
提示 error C2143: syntax error : missing ';' before '}'
執行 cl.exe 時出錯.
uj5u.com熱心網友回復:
missing ';' before '}'少了一個分號
uj5u.com熱心網友回復:
error C2676: binary '!=' : 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' does not define this operator or a conversion to a type acceptable to the predefined operator
執行 cl.exe 時出錯.
5.obj - 1 error(s), 0
最一開始說不是可用的c++,該string加了.h就變成這樣了....
uj5u.com熱心網友回復:
輸入密碼時,那個判斷三次錯誤跳出的結束分號,改成半角的試試?uj5u.com熱心網友回復:
#include"Header.h"
#include<stdio.h>//清屏頭檔案
#include<iostream>//C++頭檔案
//C++的 <string> 和 C 的<string.h>是完全不一樣的,自己好好查一下兩個頭檔案的區別
#include<string>
using namespace std;
int main()
{
string ID,key;//進入程式所需賬號密碼
cout<<"pleace enter your username:";//管理員名
for(int i=0;i<3;i++)
{
cin>>ID;
if(ID!="admin")
{
cout<<"ID can't be found!"<<endl;
cout<<"pleace enter your username:";
if(i==2)exit(0);//三次錯誤跳出
}
else break;
}
cout<<"pleace enter your password:";//管理員密碼
for(int i=0;i<3;i++)
{
cin>>key;
if(key!="admin")
{
cout<<"key is wrong!"<<endl;
cout<<"pleace enter your password:";
//你這里的分號有問題,切記,所有符號先都切換到英文輸入法再輸入
if(i==2)exit(0);//三次錯誤跳出
}
else break;
}
readdate();//——————————————————————讀取
hello();//歡迎界面
cout<<"按任意鍵回傳"<<endl;
system("pause");
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/58956.html
標籤:數據庫及相關技術
