Hi there.
i made this function:
Code:
char* strmerge(const char str1[], char str2[])
{
int x=0, chars=0;
char str_merged[40];
while (str1[x]!='\0')
{
str_merged[chars]=str1[x];
x++;
chars++;
}
x=0;
while (str2[x]!='\0')
{
str_merged[chars]=str2[x];
x++;
chars++;
}
str_merged[chars]='\0';
return str_merged;
}
this function takes 2 strings and puts them together, but there is a problem, when i call the function like this for example:
Code:
strmerge ("Hello", "testing");
this should return Hellotesting, but instead it only "Hell" and then some random chars, for example:
"Hell└@G"
why does this happen and how can i solve it??
help pls