How to get length from a unsigned char pointer [unsigned char*] on native C++

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have code on native C++, like :<br/>
typedef unsigned char _BYTE;<br/>
_BYTE arr1[39] = <br/>
<span style="white-space:pre {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10,<br/>
<span style="white-space:pre 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x20,<br/>
<span style="white-space:pre 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x30,<br/>
<span style="white-space:pre 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};<br/>
cout << sizeof(arr1) << endl; // Its print : 39<br/>
<br/>
_BYTE* arr2 = new _BYTE[39];<br/>
cout << sizeof(arr2) << endl; // Its print : 4<br/>
<br/>
arr2 = arr1;<br/>
cout << sizeof(arr2) << endl; // Its print : 4<br/>
<br/>
How can I get length of arr2 ? length of arr2 should 39, but with this code I get 4. <br/>
Whether the code that I use it wrong?<br/>
I need help. Any suggestion to me?

View the full article
 
Back
Top