I am having difficulty defining the function prototypes and corresponding parameters when the function is called from main. Any help is greatly appreciated.
Code:
//The database
struct OpAmps {
char Name[20];
unsigned int PinCount;
double SlewRate;
//The function prototypes
void Enter(OpAmps );
int Save(OpAmps );
void Load(OpAmps );
void Sort(OpAmps );
void Display(OpAmps );
//The arguments to be passed from main, where database_length is an unsigned long and OpAmp is of type OpAmps
Enter(OpAmp[database_length], database_length);
break;
case '2':
Save(OpAmp, database_length);
break;
case '3':
Load(OpAmp, database_length);
break;
case '4':
Sort(OpAmp, database_length);
break;
case '5':
Display(OpAmp, database_length);
//the functions
void Enter(OpAmp, int length&);
{
// if the database is full, inform the user
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 >> OpAmp.Name;
cout << endl << "Enter number of pins: ";
cin >> OpAmp.PinCount;
cout << endl << "Enter slew rate: ";
cin >> OpAmp.SlewRate;
cout << endl;
length++;
}
void Open(OpAmp, int length&);
{
fstream output_file; // file stream for output
// open the file
//<enter code here>
output_file.open(DATABASE_FILENAME, ios::out);
// write length information to file
//<enter code here>
// write data to file
//<enter code here>
output_file << Name << PinCount << SlewRate << endl;
// close the file
output_file.close();
}
void Load(OpAmp, int length&);
{
fstream input_file; // file stream for input
// open the file
//<enter code here>
input_file.open(DATABASE_FILENAME, ios::in);
// load database length information from file
//<enter code here>
input_file.seekg(0*sizeof(int), ios::beg);
// load data from file
//<enter code here>
int NumberRead;
for (int i=0; i=length; i++)
{
input_file >> NumberRead
// close the file
input_file.close();
void Display(OpAmp, int length&)
{
int i = 0
// if the database is empty, inform the user
if (length=0)
{
cout << "The database is empty";
}
// if the database is not empty, display all the elements in the database
//<enter code here>
else
{
for (i=1;i=length;i++)
{
cout << OpAmp[i].Name << OpAmp[i].PinCount << OpAmp[i].SlewRate << endl;
}
}
}
//Sort is not defined at all yet, need help with the passing of the struct and the use of call by value/reference to change the value of database length as the struct entrys increase
Comment