Hey all. I'm having trouble developing an order program. Basically I have to compare two files, and validate that one equals the other. I have figured out how to determine whether the order data is valid or not, but i'm unsure how to go about writing out which pieces of the file are invalid and how to correct them from a user's input.

The main instructions indicate:

Phase I: Validate Orders.

Phase II: Review the Invalid Orders and either correct the Order if possible or once again send the uncorrectable Order to the invalid file. If you have corrected the Order, write that Order to the valid file. Any Order with more than three errors should be sent back to the invalid file automatically regardless of the type of error.
As part of the processing of the Invalid Orders I would like a count of the Original Orders and the number of valid and invalid Orders prior to correction. Following Order repair I would like the count retaken.

Hints :
There are primarily two types of errors in the Orders:
TYPO – error upon entering the Order. Perhaps the option is simply different than one in the dictionary by 2 or less characters. Correct the option in the Order and then retest the Order for validity.

OPTION NO LONGER EXISTS – The option selection no longer exits –option in the Order has more than 3 characters that are different. Delete the selection that is in error and add a corrected selection (i.e. there is a selection that is close at least 2 similar characters to the original 5). Once corrections have been made go back and retest the Order.

In both cases you need to go back and retest the Order. Don't forget to update the number of valid and invalid Orders following the updates. Please supply the correction %.

Here's my code so far, which I'm not sure is completely correct:

#include <iostream>
#include <fstream>
#include <string>

    using namespace std;

    int main()
bool Found=true;
 string str;
ifstream file ("orderdata.dat",ios::in | ios::binary);

 string str2;
ifstream file2;
int count=0;
int counttwo=0;

while(!file.eof() && Found) // The "Is found true?" check is placed at both while statements to ensure that they both end as soon as a match is found.
	file>>str; //Get the first string inside order.dat and store it.

	while (!file2.eof() && !Found) //This is one way to end our loop early, when a match is found it stops the loop
		file2>>str2; //Get the first string inside dictionary.dat and store it
		if (str == str2)
			Found = true; //This is our bool to check if a match was found.

	   str2.clear(); // erase str2 so we can check the next string in example2.dat
	str.clear(); // erase str so we can check the next string in example.dat

if (Found)
     cout<<"This order is valid. There are"<<" "<<count<<" "<<"correct components."<<endl;
    cout<<"This order is invalid. There are"<<" "<<counttwo<<" "<<"incorrect components."<<endl;

  return 0;


1) See this about using feof() 2) Write a truth table for your 2 while() statements and see what they should look like.