hi i'm trying to write a program that compares and manipulates certain characters from a string.

heres the bit i'm having trouble with.

char c;
if(c <= a && c >= x)//obvious error
//do something

is there anyway i can get this to check if 'char c' lies between 'a' and 'x'?

Hi dflatt :-)

In your code you are comparing the value of variable c to the values of variables a and x. Those variables probably don't even exist.

To compare the value of c to the characters a and x you write it like this:

if(c <= 'a' && c >= 'x')

BTW: Even if you fix this bug, the if-statement will never become true. If you want to make sure that variable c has a value between 'a' and 'x' you have to swap the <= and >= operators:

if(c >= 'a' && c <= 'x')

mbulow thanks that worked perfectly

i'd already tried that but didn't notice my error thanks for pointing that out