title: copy of temp char array from for loop to another array
body: <p>I have a function that gets a const char * data and goes through every byte of makes some bit manipulation and then adds it to another char array, so basically one byte input data should be 4 bytes and 2 bytes should be 8 bytes and so on, however I'm not getting the correct results, I'm not sure if I'm using the memcpy correctly here, any help would be appreciated</p>
  <pre><code>int encryptDataAndSend(const char *logName, const char *data)
  {
    const int len = strlen(data);
    printf(&quot;data length: %d \n&quot;, strlen(data));
    char encryptedData[len * 4];
    for (uint8_t i = 0; i &lt; len; i++)
    {
      uint8_t v1 = 255;
      uint8_t v2 = 255;
      uint8_t v3 = 255;
      uint8_t v4 = 255;
  
      char temp[4] = {0};
  
      printf(&quot;char is %d \n&quot;, data[i]);
  
      v1 |= ((data[i] &amp; (1 &lt;&lt; 0)) &lt;&lt; 2);
      v1 |= ((data[i] &amp; (1 &lt;&lt; 1)) &lt;&lt; 5);
      v2 |= ((data[i] &amp; (1 &lt;&lt; 2)) &lt;&lt; 2);
      v2 |= ((data[i] &amp; (1 &lt;&lt; 3)) &lt;&lt; 5);
      v3 |= ((data[i] &amp; (1 &lt;&lt; 4)) &lt;&lt; 2);
      v3 |= ((data[i] &amp; (1 &lt;&lt; 5)) &lt;&lt; 5);
      v4 |= ((data[i] &amp; (1 &lt;&lt; 6)) &lt;&lt; 2);
      v4 |= ((data[i] &amp; (1 &lt;&lt; 7)) &lt;&lt; 5);
      temp[0] = v1;
      temp[1] = v2;
      temp[2] = v3;
      temp[3] = v4;
      printf(&quot;temp: %s \n&quot;, temp);
      memcpy(encryptedData, temp, strlen(temp));
    }
    printf(&quot;temp var: %s&quot;, encryptedData);
    const int txBytes = uart_write_bytes(UART_NUM_2, encryptedData, strlen(encryptedData));
    ESP_LOGI(logName, &quot;Wrote %d bytes&quot;, txBytes);
    ESP_LOG_BUFFER_HEX(&quot;SENDDATA_TAG&quot;, encryptedData, txBytes);
    return txBytes;
  }
  </code></pre>
  <p>This is how I call the function</p>
  <pre><code>encryptDataAndSend(TX_TASK_TAG, &quot;@BF&quot;);
  </code></pre>