I want to connect two C-style character strings and store the result in a dynamic char array.
int main()
{
char word1[] = "hello";
char word2[] = "haha";
auto ptr = new char[20];
strcpy(ptr,strcat(word1,word2));
cout<<ptr<<endl;
return 0;
}
The compiler says there is a "segmentation fault" at the statement strcpy(ptr,strcat(word1,word2));
. Why does the compiler say that?