我在循环中使用getline()。在第一个循环中,除了最后一个getline()外,所有内容都运行正常。在第二个循环中,第一个getline()似乎已被跳过。下面是环:如何在循环中使用getline C++
while(true)
{
cout <<endl<< "Enter Student's Name: ";
getline(cin,tmp_name);
cout << "Enter Student's RegNo: ";
getline(cin,tmp_regno);
cout << "Enter Student's marks: ";
cin>>tmp_marks;
mystudents.push_back(student(tmp_name,tmp_regno,tmp_marks));
mystudents[no_ofStudents].getGrade();
no_ofStudents++;
cout<<endl<<endl<<"Do you wish to continue? To continue enter yes or any other key to stop: ";
getline(cin,continue_stop);
if (continue_stop!="yes"&&continue_stop!="YES")
break;
}
是什么类型continue_stop? – 4pie0
请显示所有相关数据类型! –
这些是数据类型: int no_ofStudents = 0; string tmp_name; int tmp_marks; string tmp_regno; vector mystudents; –