I have this function within my program, it allows the user to enter things into a database, the only problem is, when i use the program i cannot get out of the enter operational amplifier stage, when i add a break into the code i get an error of illegal break, how do i fix this??
Code:
void Enter(OpAmps& OpAmp, unsigned long& length)
// if the database is full, inform the user
{
char line[20];
unsigned int Pin;
double Slew;
bool cont=false;
if (length == 10)
{
cerr << "The database is full" << endl;
}
// if the database is not full, get the data from the user and alter the database length
else
cout << "Enter Operational Amplifier name: ";
cin.ignore();
while(cin.getline(line, sizeof(line), '\n'));
{
strcpy_s(OpAmp.Name, line);
//this is where the break gets added and error is produced.
}
while (cont==false)
{
cout << endl << "Enter number of pins: ";
cin.getline(line, sizeof(line), '\n');
if (scanf_s(line,"%u",&Pin), '\n')
{
OpAmp.PinCount=Pin;
cont=true;
}
else
{
cout << "Try again" << endl;
cont=false;
}
}
cont = false;
while (cont==false)
{
cout << endl << "Enter slew rate: ";
cin.getline(line, sizeof(line), '\n');
if (scanf_s(line,"%f",&Slew))
{
OpAmp.SlewRate=Slew;
cont=true;
}
else
{
cout << "Try again" << endl;
cont=false;
}
cout << endl;
length++;
cout << "Operator Amplifier in memory, to save select option 2 from main menu" << endl;
}
}
Comment