10/25/2018 - 11:10 PM

get exact number of bytes in memory using uint8_t from <stdint.h>

uint8_t buffer[512];

Basically, <stdint.h> is a new C/C++ header that defines a bunch of cross-platform types that you can use when you need an exact number of bits, with or without the sign.

It's very useful when you do computations on bits, or on specific range of values (in cryptography, or image processing for example) because you don't have to "detect" the size of a long, or an unsigned int, you just "use" what you need. If you want 8 unsigned bits, use uint8_t like you did.

And I insist on the fact that it's cross-platform, you can compile your program on a 64-bits Linux and a 32-bits Windows, and you won't have to change the types.