以下は、生徒データを学生構造の配列に入力するために使用している関数のコードです。私はループが終了するとき、私は限界に達しています(n)、または、これは私が問題を抱えているのですが、生徒の名前のために空白行が入力されていますか?誰か提案はありますか?私が使用している現在の方法では動作しません( 'cin.getline(PA [i]の.fullname、SLEN - 1);' 以下のif文)cinを使って空白行をテストする方法
int getinfo(student pa[], int n)
{
cout << "\nPlease enter student details:\n\n";
int i;
for (i = 0; i < n; i++)
{
cout << "Student " << (i + 1) << ": \n";
cout << " > Full name: ";
cin.getline(pa[i].fullname, SLEN - 1);
if (pa[i].fullname == NULL)
continue;
cout << " > Hobby: ";
cin.getline(pa[i].hobby, SLEN - 1);
cout << " > OOP Level: ";
cin >> pa[i].ooplevel;;
cin.get();
cout << endl;
}
cout << "--------------------------------------" << endl;
return i;
}
続けます。休憩する必要があります。 –