I\'m using this code to move pointer by 1 byte now, but I\'m feeling something unclear..
int* a = (int*)malloc(sizeof(int));
void* b = ((char*)a)+1;
In C99, you have the stdint.h
header, which contains int8_t
and uint8_t
types, which are guaranteed to be 8 bits (and generally are just typedefs for char). Beyond this, there is no real language level support for bytes in C or C++, in fact the standard goes out of its way to say that sizeof
for example is in units of char
(and not bytes). There is also the CHAR_BIT
macro which tells you the number of bits in a byte, on some platforms char
was 9bits for example. Of course I'm assuming by byte you mean octet.