define macro in C wont work

Posted by Spidfire on Stack Overflow See other posts from Stack Overflow or by Spidfire
Published on 2010-05-09T12:53:27Z Indexed on 2010/05/09 12:58 UTC
Read the original article Hit count: 152

Filed under:
|

Im trying to make a macro in C that can tell if a char is a hex number ( 0-9 a-z A-Z)

#define _hex(x) (((x) >= "0" && (x) <= "9" )||( (x) >= "a" && (x) <= "z") || ((x) >= "A" && (x) <= "Z") ? "true" : "false")

this what ive come up with but it wont work with a loop like this

char a;
     for(a = "a" ; a < "z";a++){
        printf("%s  => %s",a, _hex(a));
     }

but it gives a error

 test.c:8: warning: assignment makes integer from pointer without a cast
test.c:8: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer
test.c:9: warning: comparison between pointer and integer

© Stack Overflow or respective owner

Related posts about c

    Related posts about macros