Compare char to hex value

Without all the includes and other stuff, this is generally what I'm dealing with.

char c:

c = getche();

//now need to do an if and compare if c is equal to hex value 3b or something
//similiar.


//may be way off here but is this close or what

if (0xc == 0x3b) {

goto somethingelse ;

};



somethingelse:
puts ("message");
//pause somehow;
return;


Thanks
if (c == 0x3b) {
I think you get the hexvalue notation in C++ wrong. Yes, you put 0x in front of a number to indicate that it is a "number written in hexadecimal notation". Notice that it is a notation to write numbers down. Writting c == 59 will be the same as c == 0x3b. So it is just the same number, whether you write it in hex or not. Putting 0x in front of a variable name will result in a syntax error. 0x (and 0X) are only needed when you want to write down numbers in hexadecimal notation.
Topic archived. No new replies allowed.