The original program is like this:
Int len=10;
Buff uint8_t *=new uint8_t (len);
Memcpy (buff, SRC, len);
Printf (" % x ", buff [i++]);
My attempt is like this:
Int len=10;
From & lt; Uint8_t * & gt; Buff (new uint8_t [10]);
Memcpy (buff, SRC, len);//visit an error, can't will buff to a void *
Printf (" % x ", buff [i++]);//visit an error, there is no operator to match the "[]"
Make_share also cannot use
Can you tell me how to use only Pointers here?
CodePudding user response:
Doesn't seem to support the operator from [], seems to be a c + + support after 17To switch to unique_ptr.
//from & lt; Uint8_t & gt; Buff (new uint8_t [10], default_delete & lt; Uint8_t [] & gt; ());
Unique_ptr & lt; Uint8_t [] & gt; Buff (new uint8_t [10]);
Memcpy (buff. The get (), SRC, len);
Printf (" % x ", buff [i++]);