How do I copy an int
(or any other data type) byte-by-byte to a vector<unsigned char>
?
int x = 10;
std::vector<unsigned char> byteArray(sizeof(int));
std::copy(byteArray.begin(), byteArray.end(), x); // how do I use x here?
If not possible with std::copy
, can it be done with memcpy
or any other technique?