- Joined
- Feb 22, 2003
- Location
- Montgomery
Can anyone look at my code below and tell me why I can't get my program to find the word is in a sentence?
The whole program isn't on here but I have it where it will count the number of letters in a sentence and words but for some reason I can't get it to find or count characters.
Please Help I'm ready to quit.
Thanks in advance,
Jason
//Prototype
void isSentence(string &);
//Where I call on isSentence
isSentence(sentence);
//function
void isSentence(string &sentis)
{
int position = 0;
int x = 0;
int count = 0;
while (position < sentis.size())
{
x = sentw.find("is ", position);
if (x > 0)
{
count ++;
position = x + 2;
x = 0;
}else
position = sentis.size();
}
cout << count + 1 << endl << endl;
}
The whole program isn't on here but I have it where it will count the number of letters in a sentence and words but for some reason I can't get it to find or count characters.
Please Help I'm ready to quit.
Thanks in advance,
Jason
//Prototype
void isSentence(string &);
//Where I call on isSentence
isSentence(sentence);
//function
void isSentence(string &sentis)
{
int position = 0;
int x = 0;
int count = 0;
while (position < sentis.size())
{
x = sentw.find("is ", position);
if (x > 0)
{
count ++;
position = x + 2;
x = 0;
}else
position = sentis.size();
}
cout << count + 1 << endl << endl;
}