Read and compare two textfiles.

I'm writing a program that reads two files and compares them. One file holds chunks of strings that are to be matched to places in the other, big file. Up till now most of what I got is quasi code. It goes like this:

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
int main()
{

	//Read reference file exit if trouble
	ifstream refFile("test_reference.txt");  //some 100Mb
	if(!refFile)
	{
		cerr << "Error : Reference file could not be opened." << endl;
		exit(1);
	} else {
		//If refFile could be opened, read search file, exit if trouble.
		ifstream sFile("test_part.txt");
		if(!sFile)
		{
			cerr << "Error : Search file could not be opened." << endl;
			exit(1);
		}
	}

	while(refFile.is_open()){
		while(sFile.is_open()){
			//Buffer entire refFile
			//read sFile line by line.
			//
			if(/* compare string (one line) in sFile with refFile */){
				//return place where hit, exit. Next line in search file.
			} else {
				reverse string
			}
			
			if(/* compare reversed string (one line) in sFile with refFile */){
				//return place where hit, negative to part from unreversed, exit.  Next line in search file.
			} else {
				return 0; //No hit
			}
		}
	}

I'm helping my girlfriend with some genome stuff. (Shes a post doc in biology.) I like to do this hasty, but I don't know how to manipulate, compare strings read from file in c++. Specially the part where I written buffer files, but any help is appreciated! :-)
I don't understand you
¿could you please post an example run?
refFile:
Hi i'm tinkering with strings

sFile:
with

With the given files above I like to run the program and get:
Match: with at 18 in refFile
1
2
3
getline(ref_file,reference);
src_file >> source;
reference.find(source);


refFile:
The quick brown fox jumps over the lazy dog
free alcohol beer 25 dollars
the fox and the hound
nothing to see here

sFile:
fox
bat
dog
the

¿output? (with a little explanation)
Last edited on
Topic archived. No new replies allowed.