Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your code absolutely garbage. Some notes:</p> <p><strong>Use sizeof</strong></p> <p>Use sizeof(static_massive_name); or count_of_arr_elements * sizeof(arr_type); For example:</p> <pre><code>unsigned char src[255]; unsigned char dst[255]; // fill src with random data for (int i = 0; i &lt; 255; ++i) { src[i] = static_cast&lt;unsigned char&gt; (rand() % 255); } memcpy(src, dst, sizeof(dst)); // now dst will have copyed values from src (random numbers) </code></pre> <p><strong>UPDATE</strong>:</p> <p>Full source code for testing:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; #include &lt;time.h&gt; #include &lt;stdlib.h&gt; using namespace std; void print(unsigned char* arr, size_t size) { for (size_t i = 0; i &lt; size; ++i) { // see type casting (to int)!!! cout &lt;&lt; "arr[" &lt;&lt; i &lt;&lt; "] = " &lt;&lt; (int)arr[i]&lt;&lt; endl; } } int main() { srand(time(0)); // unsigned char type hold values from 0 to 255 unsigned char src[15]; unsigned char dst[15]; for (int i = 0; i &lt; 15; ++i) { src[i] = rand() % 255; } memcpy(src, dst, sizeof(dst)); print(src, 15); print(dst, 15); return 0; } </code></pre> <p>result</p> <pre><code>arr[0] = 34 arr[1] = 80 arr[2] = 183 arr[3] = 112 arr[4] = 18 arr[5] = 120 arr[6] = 183 arr[7] = 0 arr[8] = 0 arr[9] = 0 arr[10] = 0 arr[11] = 57 arr[12] = 137 arr[13] = 4 arr[14] = 8 arr[0] = 34 arr[1] = 80 arr[2] = 183 arr[3] = 112 arr[4] = 18 arr[5] = 120 arr[6] = 183 arr[7] = 0 arr[8] = 0 arr[9] = 0 arr[10] = 0 arr[11] = 57 arr[12] = 137 arr[13] = 4 arr[14] = 8 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload