Syntax problem with "If"

So I have this little function here. I'm using that if to search for a vowel inside the string I'm analysing.

Apparently, the syntax is fine ( typical if(condition){ ...

But I'm getting this error from the compiler:

error: expected ')' before "Letra"

1
2
3
4
5
6
7
8
  string Busca_vocal (string Letra, int pos){

if(Letra.substr(pos,1)=="a" || Letra.substr(pos,1)=="e" Letra.substr(pos,1)=="i" || Letra.substr(pos,1)=="o"Letra.substr(pos,1)=="u" ||
 Letra.substr(pos,1)=="A"Letra.substr(pos,1)=="E" || Letra.substr(pos,1)=="I"Letra.substr(pos,1)=="O" || Letra.substr(pos,1)=="U"){
    return "";
    }
else return Letra.substr(pos,1);
}


I divided that long codeline in 2 so you can read it in an easier way, in the original code it's just a huge line.

Any ideas on what am I doing wrong?
Thanks a lot for your time!
Last edited on
If you put just one condition per line, a pattern should emerge. As you see here, there are a few spaces and operators missing.
1
2
3
4
5
6
7
if (Letra.substr(pos,1)=="a" 
 || Letra.substr(pos,1)=="e" 
    Letra.substr(pos,1)=="i" 
 || Letra.substr(pos,1)=="o"Letra.substr(pos,1)=="u" 
 || Letra.substr(pos,1)=="A"Letra.substr(pos,1)=="E" 
 || Letra.substr(pos,1)=="I"Letra.substr(pos,1)=="O" 
 || Letra.substr(pos,1)=="U") 


There is a lesson here: very long lines are difficult to read, it's sensible to continue on a new line rather than scrolling endlessly to the right.
Last edited on
Oh gosh, how couldn't I just see that. A bad copy paste... Thank you, I'm gonna try it again.
Working just like heaven, problem solved. :)
Topic archived. No new replies allowed.