I simply would like to open a file named "test.txt" that contains:
cat
dog
moose
rabbit
I then want to read from the file and convert its contents into strings for things that I will do later in the program. So far i think what I am doing is going in the right direction. However, I am getting an error and I am unsure what to do. Here is the Error>>>
$ make -f makefile.txt
g++ -g -D HASH_TABLE_SIZE=10 -c hash.cpp
hash.cpp: In member function `void Hash::processFile(std::string)':
hash.cpp:12: error: no match for 'operator>>' in 'my_infile >> word'
makefile.txt:6: recipe for target `hash.o' failed
make: *** [hash.o] Error 1
Here is the code I have so far (it will not compile because of that)
void Hash::processFile(string filename)
{
string word;
Hash HashTable;
ifstream my_infile(const char* filename, ios_base::openmode mode = ios_base::in);
while(my_infile >> word)//iterate through the file and hash them (handles collisions too)
{
//Insert keys and handle collisions
}
}