0
I am trying to make a function which count the syllable pls someone can tell me that what is the mistake
4 Réponses
+ 3
#include <iostream>
#include<string>
using namespace std;
int syllableCount(string s){
int count = 0;
int len=s.length();
for(int i = 0; i<len; i++){
if(s.at(i) == '-'){
count = count + 1;
}
}
return count ;
}
int main() {
cout<<syllableCount("buf-fet")<<endl;
cout<<syllableCount("beau-ti-ful")<<endl;
cout<<syllableCount("mon-u-men-tal")<<endl;
cout<<syllableCount("on-a-mat-o-pee-ia")<<endl;
return 0;
}
'-' not "-", character and string are different .
and you can get length first before comparing it with integer otherwise it will throw a warning saying comparison between int and long unsigned int .
+ 1
Thanks bro I got it
0
Value enclosed inside 'a' like this is called character right if I am wrong pls correct me
0
Yes