// require user to enter name and handicap, if the name is exist, then return 1, or return 0.
int setgolf(golf & g)
{
string temp;
cout << "Name: ";
getline(cin, temp);
if (temp == "") // whether temp is empty.
{
std::cout << "No name here. Bye!";
return 0;
} else
strcpy(g.fullname, temp.c_str());
int score;
cout << "Handicap: ";
cin >> score;
cin.get();
if(!score)
return 0;
g.handicap = score;
return 1;
}
这里注意 temp.c_str()
转载于:https://www.cnblogs.com/TadGuo/p/8178654.html