I have this typedef
typedef unsigned char uint8;
and this variable
public : uint8* bufferOfExchange;
how could I initialize this buffer?
bufferOfExchange = ???
I have this typedef
typedef unsigned char uint8;
and this variable
public : uint8* bufferOfExchange;
how could I initialize this buffer?
bufferOfExchange = ???
Like this:
bufferOfExchange = new uint8[bufferSize]; //bufferSize is size_t type.
//or
bufferOfExchange = otherBuffer; //otherBuffer is of same type
What else do you think?
Better choice would be to use std::vector<uint8>
instead of uint8*
:
std::vector<uint8> bufferOfExchange;
Now, read some good book to know how to use std::vector
.
Well you don't have a buffer, only an uninitialized pointer. You can create a buffer with new like this:
bufferOfExchange = new uint8[10];
(10 is an arbitrary choice - use the buffer size you need.)
For real code however, you would probably want std::vector<uint8>
.