Make your own free website on Tripod.com

Common Error

 

What is wrong with the following?

 

int std_Number = 0;

while (std_Number != -1)

{

     cout << "Enter student number (-1 to quit)" << endl;

     cin >> std_Number;

     InsertItem(std_Number);

}   

 

 

 

How to correct?

int std_Number = 0;

     cout << "Enter student number (-1 to quit)" << endl;

     cin >> std_Number;

     while (std_Number != -1);

     {

          InsertItem(std_Number);

          cout << "Enter student number (-1 to quit)" << endl;

          cin >> std_Number;

     }