Hi,
I'm trying to compare two text files (outputs from a database and corresponding spatial table in a GIS) to check for errors. Basically, i'm assuming that the output from the database is correct and any missing/repeat numbers in the spatial table will be errors and should be reported. I've written the part of the program that searches for a specific number in the spatial output and returns the errors, but i can't work out how to change the number it's searching for.
Here's what i've done so far:
#include <string>
#include <fstream>
#include <iostream>
#include <stdlib.h>
using namespace std;
fstream DBinput("DB.txt", ios::in);
fstream SPinput("SP.txt", ios::in);
fstream output("Errors.txt", ios::out);
int i = 0;
string correct;
string word;
void count(void);
void SPcompare(void);
void main(void)
{
while(DBinput >> correct)
{
//////// Presumably this is where the 'find number to search for' part should come in ////////
SPcompare();
}
}
void SPcompare(void)
{
while(SPinput >> word)
{
count();
}
if(i == 0)
output << "Error - '" << word << "' has no matches in spatial database" << '\n';
else if(i > 1)
output << "Error - '" << word << "' has " << i << " matches in spatial database" << '\n';
}
void count(void)
{
if(word == "5")
i++;
}
As you can see, so far it only searches for how many times the specific number 5 appears in the SP.text file.
What i'd like it to do is read the DB.txt file, find the first number to search for, then find out how many times it appears in SP.txt, then move on to the next number in DB and repeat until the end, generating a txt file output of all the errors. The SP.txt file has every number containted within inverted commas, and the DB.txt file has each number at the beginning of a new line follow by a lot of " delineated text/
Any help would be greatly appreciated, as would any 'you're making this a lot more complicated that it needs to be, here's how you can solve your problem in fifteen seconds' :)
P.S apologies for length