coolbeanbob 17 Junior Poster

Help! Why am I getting the following error on line 100?? I don't get an error when I use storage in other places?

error C2065: 'storage' : undeclared identifier

#include "utility.h"

struct masterFile                                         // master file record
{
  int employeeID;
  string employeeName;
  string departmentID;
  int YTDhoursRegular;
  int YTDhoursOvertime;
  double regularPayRate;
  double overtimeFactor;
  double ytdPay;
};

struct transactionFile                                    // transaction file record
{
  int employeeID;
  int regularHoursWorked;
  int overtimeHoursWorked;
};

struct workingStorage                                     // working storage 
{
  //copy master record
  int employeeID;
  string employeeName;
  string departmentID;
  int YTDhoursRegular;
  int YTDhoursOvertime;
  double regularPayRate;
  double overtimeFactor;
  double YTDPay;

  //new valu7es for computations
  double overtimePayRate;
  int hoursRegular;
  int hoursOvertime;
  double weeksPay;
  double newYTDPay;
  int newYTDhoursRegular;
  int newYTDhoursOvertime;
};

void readMasterFile(masterFile &myStruct, ifstream &finMaster);
void readTransactionFile(transactionFile &transactionFile, ifstream &finTransaction);
void writeNewMasterFile();
void writeNewTransactionFile();
void saveStorage(masterFile &master, workingStorage &storage);
int main()
{	
	// Open input files
	string fileNames[2] = {"employee.txt", "timeCard.txt"}; 
	ifstream finMaster(fileNames[0].c_str());
	if (!finMaster.is_open())
	{
		cout << endl << "Unable to open input file" << fileNames[0]	<< endl;
		return 1;
	} // End if (!finMaster.is_open())

	ifstream finTransaction(fileNames[1].c_str());
	if (!finTransaction.is_open())
	{
		cout << endl << "Unable to open input file" << fileNames[1]	<< endl;
		return 1;
	} // End if (!finMaster.is_open())


	// Read an old master file record
	masterFile master;
	readMasterFile(master, finMaster);
	transactionFile transaction;
	readTransactionFile(transaction, finTransaction);
	int activeKey = 0;

	
	//while()
		// If both master key and transaction key = "infinity", exit the loop.
		if(master.employeeID && transaction.employeeID == 2147483647)
		{
			//break;  // uncomment this. I had to comment because I had not set up the loop.
		}
		// Save the smallest key value from the master and transaction key as the "activeKey".
		if(master.employeeID < transaction.employeeID)
		{
			activeKey = master.employeeID;
		}
		else
		{
			activeKey = transaction.employeeID;
		}
		//If master key > active key, signal an error.
		if(master.employeeID > activeKey)
		{
			cout << "Error: Master key is greater than activeKey" << endl;
			return 1;
		}
		//If master key matches active key move the old master values to working storage
		if(master.employeeID == activeKey)
			workingStorage storage;
			saveStorage(master, storage);










}

//Post: Next record of master file is read into 
//masterFile struct
void readMasterFile(masterFile &myStruct, ifstream &finMaster)
{
	if(!finMaster.end)
	{
		myStruct.employeeID = 2147483647;
	}
	else
	{
		finMaster >> myStruct.employeeID;
		finMaster >> myStruct.employeeName;
		finMaster >> myStruct.departmentID; 
		finMaster >> myStruct.YTDhoursRegular;
		finMaster >> myStruct.YTDhoursOvertime;
		finMaster >> myStruct.regularPayRate;
		finMaster >> myStruct.overtimeFactor;
		finMaster >> myStruct.ytdPay;
	}
}


//Post: Next record of transaction file is read into 
//transactionFile struct
void readTransactionFile(transactionFile &transactionFile, ifstream &finTransaction)
{
	if(finTransaction.end)
	{
		transactionFile.employeeID = 2147483647;
	}
	else
	{	
		finTransaction >> transactionFile.employeeID;
		finTransaction >> transactionFile.regularHoursWorked;
		finTransaction >> transactionFile.overtimeHoursWorked;
	}
}

void saveStorage(masterFile &master, workingStorage &storage)
{
  storage.employeeID = master.employeeID;
  storage.employeeName = master.employeeName;
  storage.departmentID = master.departmentID;
  storage.YTDhoursRegular = master.YTDhoursRegular;
  storage.YTDhoursOvertime = master.YTDhoursOvertime;
  storage.regularPayRate = master.regularPayRate;
  storage.overtimeFactor = master.overtimeFactor;
  storage.YTDPay = master.ytdPay;

}