Determining if a string is valid

Hey folks, I'm up late on a project and have run into an issue. I'm trying to get a lookup piece of code to read from a file and determine if there is a code that matches it to decode it with. It's similar to the Huffman Code, if that's familiar to you. It takes a character from a file, checks it, and if it doesn't match anything in the recognition code, it will add another character from the input file until it matches a code segment. However, the error I've come into has been finding out what conditional will allow me to check if a sequence has been found and returned - i.e., a piece of code in the translation segment fits the string of characters I have. I can't seem to figure out how to get it to move forward if it matches. Any help would be much appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
string HuffmanDecode (string inputFilename, string outputFilename){
ifstream inFile;
ofstream outFile;
char test;
string target = "";

inFile.open(inputFilename.c_str());
outFile.open(outputFilename.c_str());
while(!inFile.eof){
if(target != ){ // This is the piece I'm having trouble with.
test = inFile.get();
target = test + target;
}
else{
outFile << target;
target = "";
}
}

inFile.close();
outFile.close();

return target;
}
Topic archived. No new replies allowed.