What is the C++ (and or visual-C++) analog of C# byte[]
?
byte[]
, in C#, is an array of unsigned 8-bit integers (byte
).
An equivalent would be uint8_t array[]
.
uint8_t
is defined in stdint.h (C) and cstdint (C++), if they are not provided on your system, you could easily download them, or define them yourself (see this SO question).
The closest equivalent type in C++ would be a dynamically created array of "unsigned char" (unless you're running on a processor that defines a byte as something other than 8 bits).
So for example
in C#
byte[] array = new byte[10];
in C++
unsigned char *array = new unsigned char[10];
In C++ standard, char
, signed char
and unsigned char
are three available char types. char
maybe signed
or unsigned
, therefore:
typedef signed char sbyte;
typedef unsigned char byte;
byte bytes[] = { 0, 244, 129 };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With