Program comparing two files

I'm still a beginner at c++ and i'm required to write a program that compares two files, an orders.txt and dictionary.txt that
1.)validates orders, if correct send to valid.txt
and
2.)review invalid orders and either correct the order if it is different by two or less orders, if three or more sent it to invalid.txt
3.)supply correction %

Problems I'm having:
Dictionary.txt is set up as

Component 1 = {AAAAC or AAAAB or AAAAD}
Component 2 = {CCCC5 or CCC14}
etc.

Orders.txt is set up as

AAAAC BBBBE CCCC5 ABCD4 QQQ3R ERFG8
AAAAB CCC14 QQQQD ZZZZ4 ZE_B12
AAAAC BBBBE CCCC5 ABCD4 QQQ3R ERFG8 PPP14 REWD2
etc.

-I need to put in a new line at the end of an order but it's not working properly. After QQQ3R it grabs ERFG8AAAAB.I don't know how to output the valid.txt in the same fashion it was given in. The way i currently have it, it appends to one continuous line instead of a
'/n' after the item "ERFG8" to go to the next line.
-I could use a push in the right direction as to how to look at character differences and correct the order if it differs by 2 or less characters.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
#include<stdio.h>
using namespace std;
bool checkInvalid(string order, char dictionary[])
	{
		ofstream valid;
		char *pch;
		int count=0;
		int sizeOf=0;
		char seps[]=" ={}";
		char *next_token;
		pch = strtok_s(dictionary,seps,&next_token);
		char *strOrder= (char*)order.c_str();
		while(pch != NULL)
		{
			if(strcmp(strOrder,pch)==0)
			{
						valid.open("Valid.txt", ios::out | ios::app);
						valid<<strOrder<<" ";
						valid.close();		
						return true;
			}
			if(order == "")
			{
						valid.open("Valid.txt", ios::out | ios::app);
						valid<<"\n";
						valid.close();		
						order.clear();
						return true;
			}
				
			pch=strtok_s(NULL,seps,&next_token);
		}
		return false;
	}
int main()
{
	string strOrders;
	string strDictionary;
	ifstream orders;
	bool found=false;
	orders.open("Orders.txt");
	while(getline(orders,strOrders,' '))
	{
		found = false;
		ifstream dictionary;
		dictionary.open("Dict_Orig.txt");
		while(getline(dictionary,strDictionary) && found == false)
		{	
			//take strDictionary and convert it to array
			char *strDic= (char*)strDictionary.c_str();
			found = checkInvalid(strOrders,strDic);
			strOrders.clear();
		}
	}
	system("PAUSE");
	return 0;
}

Topic archived. No new replies allowed.