NEW Specific IF question

My IF is preventing me from correctly validating an array of chars properly. Each char has it's own class as shown below. I am only capable of classying white spaces, numbers, signs and letters.

charType dot is used for decimal places, but for some reason, the statement interprets that it's a sign (+/-)

charType Ee is for exponents, but I can't seem to isolate it. It's treated as a letter even if the item to it's left (known as char c) is a digit.

Here is the statement:

charType getCharType(char a,char c) //getCharType is an process that identifies the characters accordingly
{ charType b;

if(isspace(a))
b = white;
else if(isalpha(a)) //identify all letters
b = letter;
else if(isdigit(a)) //identify all digits
b = digit;
else if(a='-')
b = sign;
else if(a='+')
b = sign;
else if(a='.') //identify the dot
b = dot;
else if((a='E')&&(isdigit(c))) //identify exponents
b = Ee;
else if((a='e')&&(isdigit(c))) //identify exponents
b = Ee;
return b;
}

Previously resolved IF question:

Hello again, It's been a while since I've tried this, but I need to validate whether a char is between a and z. this is what I wrote, perhaps someone can help me out:

string b;
if((a >= "a")&&(a <= "z")||(a >= "A")&&(a<="Z"))
b = "word";
Last edited on
Change all the " " to ' ' and it should work.
Last edited on
I have a new issue I need help with.

The above had resolved my previous issue. Thank you very much firedraco.
Last edited on
I assume you replaced all the

if( a='x' )

with

if( a == 'x' )

also.


And there is a logic bug in that isalpha() will return true if a == 'E' long before you check for ( a == 'E' ) && ( isdigit( c ) )

Topic archived. No new replies allowed.