vendredi 8 mai 2015

How to escape from hex to decimal

I apologise if this is an obvious question. I've been searching online for an answer to this and cannot find one. This isn't relevant to my code per se, it's a curiosity on my part.

I am looking at testing my function to read start and end bytes of a buffer.

If I declare a char array as:

char *buffer;
buffer = "\x0212\x03";

meaning STX12ETX - switching between hex and decimal.

I get the expected error:

warning: hex escape sequence out of range [enabled by default]

I can test the code using all hex values:

"\x02\x31\x32\x03"

I am wanting to know, is there a way to escape the hex value to indicate that the following is a decimal value?

Aucun commentaire:

Enregistrer un commentaire