c - there is an error shows up to be "comparison between pointer and integer ('int' and 'const char *')" -



c - there is an error shows up to be "comparison between pointer and integer ('int' and 'const char *')" -

char * piglatin(const char s[], int len) { char * result[len+3] = s[]; char * current[len+3] = s[]; if(s[0]=="o"||"u"||"e"||"a"||"i"){ result[len-1] = "y"; result[len-2] = "a"; result[len-3] = "-"; } else{ for(int = 0; i<len-1; i++){ result[i] = current[i+1]; result[len-1] = "-"; result[len] = current[0]; result[len+1] = "a"; result[len+2] = "y"; } } }

i met problem when doing programme homework computer science class. professor want append "-ay" after string s if first letter of s vowel, otherwise remove first letter of s , append "-?ay". error appears @ "if(s[o]=="o"||"u"||"e"||"a"||"i")" , said "comparison between pointer , integer ('int' , 'const char *')". sense confused since s not pointer , right hand side not integer either.

there 2 issues here. compiler complaining because s[0] char , "o" (and others) pointers char arrays (basically). prepare this, replace "o" 'o'.

there's bigger issue though: comparing s[0] 'o'. other things in test evaluate true:

if(s[0]=='o'||s[0]=='u'||s[0]=='e'||s[0]=='a'||s[0]=='i'){

c pointers

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -