做循环不起作用C ++

时间:2014-04-28 23:44:04

标签: c++ while-loop do-while

我很确定这个Do While Loop应该可行。但它没有。我不知道为什么。它就停止了。如果我加!在条件面前,它只是转向无限循环。

do
{
cout <<"\nThe database details are as follow: "<< endl;
cout <<"\nSize of database = "<<sRecord.size () <<endl;
studentRecord::iterator sRecordIter;
for(sRecordIter  = sRecord.begin();
    sRecordIter != sRecord.end();
    ++sRecordIter)
    cout << 
    "\nStudent ID: " << sRecordIter->first  << 
    " Student Name: " << sRecordIter->second->getName() << endl;

    cout << "\nPlease enter ID key of student to search their record." <<endl;
    cin >> recordSearch;
    searchDatabase(sRecord,recordSearch);

    for(sRecordIter  = sRecord.begin();
        sRecordIter != sRecord.end();
        ++sRecordIter)
        if (recordSearch == sRecordIter->second->getId())
        {
            sRecordIter->second->printCourseInfo();
        }
        cout <<"Would you like to search the database again y/n?"<<endl;  // Ask user if they want to continue

        cin >> cont;
}
while ((cont == 'Y' || cont == 'y'));

0 个答案:

没有答案