我有一个简单的while循环,但是我无论如何都想不出我缺少了什么。我已经在顶部将currentuser初始化为-1。
while(currentuser = -1){
cout << "Enter user ID: ";
cin >> id;
currentuser = search(a, length, id);
}
我的搜索功能如下:
int search (User a[ ], int length, string userID){
User u;
string tempid;
int templegnth; //I ignore length for now as I will use it later
for(int i=0; i<50; i++){
tempid = a[i].getID();
templegnth = tempid.length();
if((tempid == userID)){
return i;
}
}
return -1;
}
我知道这是非常简单的事情,但现在答案却让我想不起来了。
while(currentuser == -1)
注意==
。 如果不是这样,您可以考虑实际描述问题并提出问题。 - tenfour