为什么会进入死循环,怎样修改才正确
int setgolf(golf & g){
int next;
std::cout << "Please enter golfer's full name: ";
std::cin.getline(g.fullname, Len);
if (g.fullname[0] == '\0')
return 0; // premature termination
std::cout << "Please enter handicap for " << g.fullname << ": ";
while(!(std::cin >> g.handicap))
{
std::cin.clear();
std::cout<<"please enter a integer: ";
}
while (std::cin.get() != '\n')
continue;
return 1;
}
Enter up to 5 golf team members:
Please enter golfer's full name: reg
Please enter handicap for reg: w(输入w后就进入死循环)