Hi, all
i have one assignment about using some of the STL to read from .txt file and count the words and find the topnwords etc.
So i implement my class like that:
class A
{
public:
A( const string& filename )
{
ifstream file( filename.c_str() ) ;
string word;
while( file >> word)
_word_list.push_back(word);
}
size_t wordCount(const string& word) const;
private:
vector<string> _word_list;
};
So the wordCount is to find how many word occurrence in the file
so when i implement the wordcount function, there should have one feature to judge the puctuations, so i use ispuct() function to judge it.
But i got compile error:
for(size_t i=0; i<_word_list.size(); i++)
{
if(!ispunct(_word_list[i]))
{
//do something
}
}
error information:
Error 1 error C2664: 'ispunct' : cannot convert parameter 1 from 'const std::basic_string<_Elem,_Traits,_Ax>' to 'int'