Hello i'm making a program where i have to search through a txt file and find the a word but the word should be found even if the word is "isn't" and the user entered "isnt"
cout<<"Please provide a filename: ";
cin>>userFile;
fstream doc(userFile.c_str());
if (doc)
{
while (!doc.eof())
{
doc>>tmp;
doc.erase (remove (doc.begin(), doc.end(), ' '), doc.end());
doc.erase (remove (doc.begin(), doc.end(), ','), doc.end());
doc.erase (remove (doc.begin(), doc.end(), '.'), doc.end());
b.insert(b.getRoot(),tmp);
//doc>>tmp;
}
doc.close();
doc.clear();
break;
}
else
cerr<<"File Not Found!"<<endl;
the erase feature doesnt work for me although i've seen it before i'm not sure why it doesnt work now. also this should work to find "end." when user enters end. could it be that this works for only entire lines and not individual words?
i get the errors:
h6.cpp:80:8: error: ‘std::fstream’ has no member named ‘erase’
h6.cpp:80:27: error: ‘std::fstream’ has no member named ‘begin’
h6.cpp:80:44: error: ‘std::ios_base::end’ cannot be used as a function
h6.cpp:80:61: error: ‘std::ios_base::end’ cannot be used as a function
h6.cpp:81:17: error: ‘std::fstream’ has no member named ‘erase’
h6.cpp:81:36: error: ‘std::fstream’ has no member named ‘begin’
h6.cpp:81:53: error: ‘std::ios_base::end’ cannot be used as a function
h6.cpp:81:70: error: ‘std::ios_base::end’ cannot be used as a function
h6.cpp:82:17: error: ‘std::fstream’ has no member named ‘erase’
h6.cpp:82:36: error: ‘std::fstream’ has no member named ‘begin’
h6.cpp:82:53: error: ‘std::ios_base::end’ cannot be used as a function
h6.cpp:82:70: error: ‘std::ios_base::end’ cannot be used as a function
fstream class does not have erase method.
fstream class is not container class so it does not have iterators.
string class can't be "cin'ed" cos it does not provide operator>>
You are using enums as if they where methods or iterators??
yeah your right i got all that to work but i've encountered another problem. i cannot use these methods to remove the " ' " symbol because it will say that their is a missing ' .
h6.cpp:83:56: error: empty character constant
h6.cpp:83:58: warning: missing terminating ' character [enabled by default]
h6.cpp:83:13: error: missing terminating ' character