STL algorithm merge() function to concatenate char arrays

When the STL generic algorithm's merge() function is used to merge two char arrays, the output is not as expected. Below is the program I tried with.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iterator>

using namespace std;

int main() {
    char str[] = "Hello";
    char srch[] = "World";
    char merg[strlen(str) + strlen(srch) + 1];
    std::deque<char> d(20);
    std::merge(&str[0], &str[strlen(str)], &srch[0], &srch[strlen(srch)], &merg[0]);
    std::merge(&str[0], &str[strlen(str)], &srch[0], &srch[strlen(srch)], d.begin());
    cout << merg << endl;
    std::copy(d.begin(), d.end(), ostream_iterator<char>(std::cout, ""));
    cout << endl;
}

I used both deque and char array to store the merged string. But I am getting the output as

HWelloorld
HWelloorld

But, I expected to get "HelloWorld"

str[0] is the first character in the string, str[strlen(str)] is one beyond the last character of the string, etc, etc. I have no idea how you expected to get HelloWorld.

You should not be declaring arrays with dynamic sizes. Never use things like strlen() in an array size.

STL has absolutely no purpose here since you're using C strings.

#include <string.h>
#include <stdio.h>

int main(void)
{
    char str[] = "Hello";
    char srch[] = "World";
    char output[512];

    output[0]='\0';
    strcat(output, str);
    strcat(output, srch);
    printf("output is %s\n", output);
}

Thank you Corona688 for the suggestion to use C library, but my intention was to understand the STL merge() and hence I tried it with char array.

Yes, it should be one char beyond the last character of the string, since the C string stores the terminating null '\0' char.

Why would you expect anything but "H" from a string that starts with H, then immediately has a null terminator?