Trouble comparing two string arrays

Alright everyone, I'm having trouble making c++ compare two string arrays. It compares them once, correctly, but fails to continue comparing. It's down at if statement which does the output. If it successfully compares, it will continue to look through the files. If the comparison fails, it continues looking through a file, comparing. However, it compares successfully once, then never again, and gets caught in a never-ending output loop. What am I doing wrong? Thank you so much! Here is everything:

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main () {

	string ModelType, // Stores the command Models (model, update, range, and exit) given by Script.txt
	       ComputerModel, // Model of the Computer
	       ModelName[100], // Stores the models of the computers in this array
	       ModelTypeComputers[100], // Stores the command models of the computers in this array
	       AnotherComputerModel[100], // Stores the models of the computers in this array
	       ComputerModelName, // Computer Model Names
	       ComputerName[100], // Array for computer model names
	       TheManufacturerName, // Manufacturers
	       ManufacturerName[100];  // Manufacturer arrays
	int newprice = 0, // New, updated prices specified by Script.txt
	    NewPrice[100], // Array of the new, updated prices specified by Script.txt
	    LowerBound = 0, // Lower bound
	    UpperBound = 0, // Upper bound
	    NumLines = 0, // Counter
	    Price, // Original prices of the computers
	    ComputerPrice[100], // Array for the prices
	    truelength = 0,
	    idx = 0, // Counter
	    NewLines = 0, // Counter
	    Lines = 0, // Counter
	    MoreNewLines = 0, // Counter
	    LoopCount = 0; // Counter
	ifstream iFile; // open input file stream
	iFile.open("Script.txt"); // open input file: Compsys.txt
	while (iFile) {
		iFile >> ModelType; // Start reading line
		ModelName[NumLines] = ModelType;
		iFile.ignore(4, '\t');
		if (ModelName[NumLines] == "model") {
			getline (iFile, ComputerModel, '\n'); // Continue reading the line
			AnotherComputerModel[NumLines] = ComputerModel; // Build array for the computer models supplied by the second input file
		}
		else if (ModelName[NumLines] == "update") {
			getline(iFile, ComputerModel, '\t');
			AnotherComputerModel[NumLines] = ComputerModel; // Build array for the computer models supplied by Script.txt input file
			iFile >> newprice;
			NewPrice[NumLines] = newprice; // Grab the updated prices
		}
		else if (ModelName[NumLines] == "range") {
			iFile >> LowerBound;
			iFile >> UpperBound; // Read range bounds
		}
		else if (ModelName[NumLines] == "exit") {
			break;
		}
		NumLines++;
	}
		iFile.close();

	iFile.open("CompSys.txt"); // open input file: CompSys.txt
	while (iFile) { // take in data until the data file runs out of data; puts data into arrays mentioned above and in loop
		getline(iFile, ComputerModelName, '\t'); // Getting data for ComputerModel
		ComputerName[idx] = ComputerModelName;
		getline(iFile, TheManufacturerName, '\t'); // Getting data for ManufacturerName
		ManufacturerName[idx] = TheManufacturerName;
		iFile >> Price; // Getting data for ComputerPrice
		ComputerPrice[idx] = Price;
		idx++;
	}
	truelength = idx - 2;

	iFile.close();

	ofstream oFile; // output file stream
	string it;
	oFile.open("CompLog.txt"); // open output file
	oFile << "Programmer: Evan Becker" << endl; // Build and output the header
	oFile << "CS 1044 Project 4 Fall 2011" << endl;
	oFile << "--------------------------------------------------------------------" << endl;
	//while () {
	while (LoopCount <= NumLines) {
			oFile << AnotherComputerModel[Lines] << '\t' << ComputerName[NewLines] << '\t' << MoreNewLines << '\t' << truelength << endl << endl;
			if (AnotherComputerModel[Lines] == ComputerName[NewLines]) { //The trouble is here.  C++ compares once, but not again, despite elements being the same.  I don't understand.
				Lines++;
				LoopCount++;
			}
			else {
				if (NewLines < truelength) {
				NewLines++;

				}
				else{
					oFile << AnotherComputerModel[Lines] << " not found" << endl;
				}
			}
		}
	oFile.close();
}


input files:
Script.txt:
model Brio BA600
model Gateway GP7
model Dimension 8100
model Performance 1500CX
model Vaio PCV-R558DS
update Vaio PCV-R558DS 1944
update Brio BA600 1149
range 800 1100
model PCV-LX700
exit

CompSys.txt:
Brio BA600 Hewlett-Packard 1099
Deskpro Compaq 1261
Professional AP500 Compaq 2337
Intel Pentium III Explorer Micro 777
Presario Compaq 1879
PowerMate ES NEC Computers 1356
iPaq Compaq 1849
Performance 1500CX Gateway 1999
Workstation 300 Compaq 3100
OptiPlex GX110 Dell 1108
Kayak XM600 Hewlett-Packard 2813
Dimension 4100 Dell 1609
Deskpro EX Compaq 1260
Profile 3cx Gateway 1999
Vaio PCV-R556DS Sony 1688
Essential 933 Gateway 1348
NetVista A60i IBM 2369
PowerMate CT NEC Computers 2149
PowerMate VT300 NEC Computers 1160
Dimension 8100 Dell 1808
Performance 1400CL Gateway 1599
Vaio PCV-R558DS Sony 1799
Performance 1300CS Gateway 1299
Intel Pentium IV Explorer Micro 1469
Proliant 6000 Compaq 1099
Gateway GP7 Gateway 1799

Topic archived. No new replies allowed.