I'm trying to display the output on the console, but when I run it all I get is "Join processing is starting" and that's it. Is there something that I'm doing wrong?

/ Join customer and transaction files on customer
		cout << "Join processing is starting. \n\n\n";

	transFile >> custNum_Trans >> productCode;
	custFile >> custNum >> custLastName >> custFirstName >> streetNum >>    streetName >> city >> state >> zip;
	while (!transFile.fail() )
	{
		while (!custFile.fail () )
		{	
			if (transCustNum == custNum)
		{
			shipFile << custNum << " " << productCode << " " << custLastName << "," << setw(15) << custFirstName;
		}
			if (transCustNum > custNum)
			break;
			
			transFile >> custNum_Trans >> productCode;
		}

			custFile >> custNum >> custLastName >> custFirstName >> streetNum >> streetName >> city >> state >> zip;
	
		cout << custNum << " "<< productCode <<" " << custLastName << "," << setw(15) << custFirstName;
		cout <<setw(7) << right << streetNum << " "<< streetName <<" " << city << ","<< state << " "<< zip << "\n"; 
	}
	cout << "\n\n\nClosing files.\n\n\n";
	custFile.close ();
	transFile.close ();
	shipFile.close ();
	cout << "Program has ended. \n\n\n";

}

Look at your variables in the if statement if (transCustNum == custNum) Are they the same as what you are reading into from the files?

Then, you are reading in one customer record and possibly many transactions records. This can put you out of transaction data before running out of customer data. Should you be resetting the transaction file to its start point before going on to the next customer, or vice versa?

Your loop ordering does not agree with the loop contents. Your outer loop tests transaction read success, but reads customers, the inner loop test customer read success but read transactions.

Val

This article has been dead for over six months. Start a new discussion instead.