0

I am trying to make a function which count the syllable pls someone can tell me that what is the mistake

https://code.sololearn.com/cbkB5i6jZY58/?ref=app

27th Apr 2021, 8:37 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar
4 odpowiedzi
+ 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 .
27th Apr 2021, 8:45 AM
Abhay
Abhay - avatar
+ 1
Thanks bro I got it
27th Apr 2021, 8:50 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar
0
Value enclosed inside 'a' like this is called character right if I am wrong pls correct me
27th Apr 2021, 8:51 AM
Harsh Pratap Singh
Harsh Pratap Singh - avatar
0
Yes
27th Apr 2021, 8:53 AM
Abhay
Abhay - avatar