I have the following program which fails to merge the two strings because the string1 does not have enough space to hold the merged string .When string1 doesnt have enough space and without using the additional array to hold merged string how to return a merged string ?
#include<stdio.h>
#include<string.h>
int main()
{
void strcat2(char *str1,char *str2);
strcat2("john","kris");
getchar();
}
void strcat2(char *str1,char *str2)
{
for (; *str1++;);
for (;*str1++ =*str2++;);
}