我有一个用 C++ 编写的程序,要求用户输入他/她的 11 位手机号码。但是当我输入 11 位数字时,程序continue
没有执行后续代码。
string FriendName, FriendAdd, EmailAdd;
long MobileNumber, counter, counter1, counter2;
//Create a new structure
struct personData {
string namePerson, addressPerson, emailAddress;
long age;
struct personData *next;
};
//Initialize pointers to personData structure
typedef struct personData node;
node *firstRec, *currentRec, *tempRec, *tempRec2;
void InsertRec() {
cin.ignore(200,'\n');
cout<<"Enter your Friend's Name : ";
cin.ignore(1,'\n');
getline(cin,FriendName);
cout<<"Enter your Friend's Mobile Number : ";
cin>>MobileNumber;
cout<<"Enter your Friend's Address : ";
cin.ignore(1,'\n');
getline(cin,FriendAdd);
cout<<"Enter your Friend's Email Add : ";
getline(cin,EmailAdd);
cout<<endl<<endl;
tempRec = new(personData);
tempRec->namePerson = FriendName;
tempRec->addressPerson = FriendAdd;
tempRec->emailAddress = EmailAdd;
tempRec->age = MobileNumber;
tempRec->next=firstRec;
//firstRec->next=tempRec;
firstRec=tempRec;
}