I want to concatenate a uint64_t
to unsigned char*
. I can not use sprintf()
, strcpy()
, and strcat()
because they only accept char*
as argument.
#include <cstdint>
// I want to concatenate these two:
unsigned char data[8] = "tJQVfvcj";
uint64_t num = 1732462110473334785;
The output should be equivalent to:
unsigned char concat[28] = "tJQVfvcj1732462110473334785";
The efficiency is also important, although it is the second priority. I highly appreciate any suggestions.
Edit: I used sprintf() like this:
unsigned char data[9] = "tJQVfvcj";
uint64_t num = 1732462110473334785;
unsigned char concat[28];
sprintf(concat, "%s%" PRId64 "", data, num);
However, it leads to this error:
error: invalid conversion from ‘unsigned char*’ to ‘char*’ [-fpermissive]