string - c++ character comparison between a number char and a letter char -
i have string variable named tablolar , in case it's value "tablo2" , according intension can not enter in if statement enters , couldn't find out why.
for(int z=0;z<tablolar.size();){ if((tablolar[z]==',')||(tablolar[z]=='a')||(tablolar[z]=='b') ||(tablolar[z]=='c')||(tablolar[z]=='d')||(tablolar[z]=='e') ||(tablolar[z]=='f')||(tablolar[z]=='g')||(tablolar[z]=='h') ||(tablolar[z]=='i')||(tablolar[z]=='j')||(tablolar[z]=='k') ||(tablolar[z]=='l')||(tablolar[z]=='m')||(tablolar[z]=='n') ||(tablolar[z]=='o')||(tablolar[z]=='p')||(tablolar[z]=='q') ||(tablolar[z]=='r')||(tablolar[z]=='s')||(tablolar[z]=='t') ||(tablolar[z]=='u')||(tablolar[z]=='v')||(tablolar[z]=='w') ||(tablolar[z]=='x')||(tablolar[z]=='y')||(tablolar[z]=='z')) { //enters here must not enter }
your check includes checking current symbol 't'
, , if string 'tablo2'
, it's first character 't'
.
by way, check done simplier:
if ((tablolar[z] == ',') || (tablolar[z] >= 'a' && tablolar[z] <= 'z')) // work