Hi, all
I am trying to write the function to get rid of my punctuations.
My code:

//_word_list is the vector<string> type
void TextUtil::isnotpuct() const
{	for(size_t i=0; i<_word_list.size(); i++)
	{
		size_t len = _word_list[i].length() + 1;
		for(size_t j=0; j< len;j++)
		{  if(ispunct(_word_list[i][j]))
			{  
				_word_list[i] = "";
			}
		   
		   j++;
		}
		i++;
     }

}

But i got the error:

error C2440: '=' : cannot convert from 'const char [1]' to 'const char'

Where is the problem with my code??
Many thanks.

Recommended Answers

All 2 Replies

How many times are you planning to post this code ?
I've already seen variations of this code in at least three different threads, but all with a similar question: "This code isn't compiling ..."

I'm not blaming you for this because it's a moderator's task to make a judgment about whether this is allowed or not ...

That's your problem:

void TextUtil::isnotpuct() const
{
//_word_list is the vector<string> type
...
_word_list[i] = "";
...

const member function can't modify other members. WHY this function-predicate has so drastic side effect?!

Yes, it's a ghost post... May be once morning this code will be compiled successfully...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.