• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

C++ Gurus I need help!!

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.
Status
Not open for further replies.

Procharger

Member
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;
}
 
What word are you trying to find? "is"? Is sentw a string?

Might be a good idea for a mod to move this to the programming forum.
 
Status
Not open for further replies.
Back