int textInfo::get_wordCount(void)
{
int start;
int i;
int count;
count = 0;
start = 0;
i = 0;
while (i <= text.length())
{
if (separator(text[i]) == true)
{
if (is_number(text.substr(start, i - start)) == false)
count++;
while (separator(text[i]) == true)
i++;
start = i;
}
i++;
}
return count;
}
So somewhere in here there is a problem which jams whole program , when I compile it shows no errors , but all I get is empty console window . Any ideas why ?
[code] Your code goes here [/code]
Arrays goes from 0 to n-1.
Also
1 2 3 4 5 6 7 8
if (separator(text[i]) == true)//redundant
if( separator(text[i]) )
if (is_number(text.substr(start, i - start)) == false) //obfuscated
if ( not is_number(text.substr(start, i - start)) ) // or use !
if ((word[i] < 0x30) || (word[i] > 0x39))//obfuscated
if( (word[i] < '0') || (word[i] > '9') )
@Slumdog: Don't cast the compiler errors. You are breaking the structure of the string. (also, why string if you are going to use it as a char * ?
You could use string::find or string::find_first_of instead of strtok