I am getting results from a routine which are unexpected from me.
here is athe code.
void MyTestFunc(){
u_char MyTest_u_char[10] = {'a','b','c','d','e','f','g','h','i','j'};
u_char * MyTest_u_char2 = new u_char[8];
memcpy(MyTest_u_char2,&MyTest_u_char[1],sizeof(u_char)*8);
int raw_len = sizeof(MyTest_u_char2) + 1;
string std_str(MyTest_u_char2, MyTest_u_char2 + raw_len);
cout << std_str << endl; // expecting bcdefghi . getting bcdef
}
Expected outputbcdefghi
Outputbcdef
No matter if I try to copy 8,9 or ten bytes, I only get 5 converted to std::string
Can anyone see my error?