To be const-correct, change:
Code:
static void ascii2bcd(char* outbuf, int length, char* data)
to:
Code:
static void ascii2bcd(char* outbuf, int length, const char* data)
You can then write:
Code:
bcd2ascii(data, 17, "35496200179252501");
I then move the contents of the char* outbuf into a char[] like so:
It looks like you edited the code snippet but forgot to change the variable names consistently, so now you have result, xdts5data and test.
I would now like to move the contents of result into another char[64], but I can't use strcopy because it truncates the data after the seventh character. I think this is because it is technically not a character anymore, so stops the copying.
If your char array has embedded null characters, you can still copy with a loop, or simply use std::copy() from <algorithm>. In fact, you have already written such a loop, methinks, to copy from the char* to the char[64].
EDIT:
Oh, yes, or memcpy(). By the way, have you considered using std::vector<char> or std::string?