hello all! i am working on a program that reads in a text file that the user inputs, creates a text file that the user inputs, names the text file that the user wants, and then sorts the text file sorting words above the user entered in threshold and displays the words and how many times it was found to the output file the user specify's. i have most of the code finished but im getting a compiler error heres the sample output, error and code
sample output
Enter name of input command file; press return.
history.in
Enter name of output file; press return.
history.out
Enter name of test run; press return.
sample
Enter the minimum size word to be considered.
5
Sample results (found in user specified output file):
sample
abacus 4
abstract 1
adding 1
addition 2
advances 1
after 3
where the word is the word found in the text file, and the number next to it is how many times it was found.
the error code
C:\Users\kevin jack\Desktop\prog-4>g++ -o test test.cpp
test.cpp: In function `void Process(TreeNode*&, StrType)':
test.cpp:48: error: no match for 'operator==' in 'tree->TreeNode::info.WordType:
:word == string'
test.cpp:50: error: no match for 'operator<' in 'string < tree >TreeNode::info.WordType::word'
test.cpp:51: error: 'struct TreeNode' has no member named 'eft'
test.cpp: In member function `void ListType::Print(std::ofstream&) const':
test.cpp:74: error: no matching function for call to `ListType::Print(TreeNode*
const&, std::basic_ofstream<char, std::char_traits<char> >&) const'
test.cpp:73: note: candidates are: void ListType::Print(std::ofstream&) const
and the code
//main.cpp
#include <fstream>
#include "StrType.h"
#include <cstddef>
#include <iostream>
#include <string>
using namespace std;
struct WordType
{
public:
StrType word;
int count;
};
struct TreeNode
{
WordType info;
TreeNode* left;
TreeNode* right;
};
class ListType
{
public:
ListType();
void InsertOrIncrement (StrType string);
void Print(std::ofstream&) const;
private:
TreeNode* root;
};
ListType::ListType()
{
root=NULL;
}
void Process(TreeNode*& tree, StrType string)
{
if(tree == NULL)
{
tree = new TreeNode;
tree->info.word = string;
tree->info.count = 1;
tree->left = NULL;
tree->right = NULL;
}
else if (tree->info.word == string)
tree->info.count++;
else if (string < tree->info.word)
Process(tree->eft, string);
else
Process(tree->right, string);
}
void ListType::InsertOrIncrement(StrType string)
{
Process(root, string);
}
void Print (TreeNode* tree, std::ofstream& outFile)
{
if (tree!= NULL)
{
Print(tree->left, outFile);
tree->info.word.PrintToFile(true, outFile);
outFile <<" "<< tree->info.count;
Print(tree->right, outFile);
}
}
void ListType::Print(std::ofstream& outFile) const
{
Print(root, outFile);
}
int main()
{
using namespace std;
ListType list;
string inFileName;
string outFileName;
string outputLabel;
ifstream inFile;
ofstream outFile;
StrType string;
int minimumLenght;
cout<<"enter in imput file name."<<endl;
cin>>inFileName;
inFile.open(inFileName.c_str());
cout<<"enter name of output file."<<endl;
cin>>outFileName;
outFile.open(outFileName.c_str());
cout<<"enter name of test run."<<endl;
cin>>outputLabel;
outFile<< outputLabel << endl;
cout<<"enter the min word size."<<endl;
cin>>minimumLenght;
string.GetStringFile(true, ALPHA_NUM, inFile);
while(inFile)
{
if(string.LenghtIs() >= minimumLenght)
list.InsertOrIncrement(string);
string.GetStringFile(true, ALPHA_NUM, inFile);
}
list.Print(outFile);
outFile.close();
inFile.close();
return 0;
}
//StrType.h
#include <fstream>
#include <iostream>
const int MAX_CHARS=100;
enum InType{ALPHA_NUM, ALPHA, NON_WHITE, NOT_NEW};
class StrType
{
public:
void MakeEmpty();
void GetString(bool skip, InType charsAllowed);
void GetStringFile(bool skip, InType charsAllowed,
std::ifstream& inFile);
void PrintToScreen(bool newLine);
void PrintToFile(bool newLine, std::ofstream& outFile);
int LenghtIs();
void CopyString(StrType& newString);
private:
char letters[MAX_CHARS + 1];
};
void StrType::MakeEmpty()
{
letters[0] ='\0';
}
if anyone could give me advice as to what im doing wrong or help me i would be tremendously grateful
thanks kevin