Hi all,

I want to find the number of words in a string(actually it can be a paragraph either). I found the new line character as follows.

Code:
int numberOfWords = 1;
	string st(pBuffer);

	for(int i = 0;i <= st.length(); i++)
	{
		// Newline
		if(pBuffer[i] == '\n')
		{
			numberOfWords ++;
		}

	}
My question is, say I have put more than one new line character at the end or middle of the string. All of them also count as another word of a string. How can I avoid it.