i have created a C string of my variables and guessing i need some king of loop to check each character after it gets it?

Recommended Answers

All 4 Replies

i have created a C string of my variables and guessing i need some king of loop to check each character after it gets it?

Could you please post the code you have?

#include<iostream>

using namespace std;
int main()
{
string passage;
int space=0;
int sentence=0;
int word=0;
int character;
int index;
string delimeter=".:;!?";
string syllable;
string syll="aeiou";
cout<<"enter the passage to find out readability index";
getline(cin,passage);
    for (int  i = 0; i < passage.length(); i++)
    {
        //number of words
        if (isspace(passage[i]) )
        {        
            space++;
        }
        word=space+1;
        //number of sentences
        if(character=(passage.find_first_of(delimeter)))
        {
            passage.erase(0,character+1);
            sentence++;
        }
        //number of syllables
        
    //cin.get();
    }
    syllable=passage.c_str();
    cout<<"the syllable is"<<syllable;
    
    return 0;
}

so insert something like this in my for loop?

if(int index=find_first_of(syll)
    {
         substring(0,index+1);
    }

Well, actually there are strict (language) rules for splitting up a word in syllables, so I suggest you to look them up, and implement these rules in your program.
Once you've implemented them, you can start counting the syllables in a word, sentence, text.

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.