char c[40] = strcat(a, b);
is invalid because you try to assign an array with a pointer
If you really want to use arrays :
#include <stdio.h>
#include <string.h>
char a[20] ="hello";
char b[20] = "there";
int main()
{
char c[40];
strcpy(c, a);
strcat(c, b);
puts(c);
}
or just
#include <stdio.h>
#include <string.h>
char a[20] ="hello";
char b[20] = "there";
int main()
{
strcat(a, b);
puts(a);
}
Compilation and execution :
pi@raspberrypi:/tmp $ g++ -pedantic -Wextra -Wall c.cc
pi@raspberrypi:/tmp $ ./a.out
hellothere
pi@raspberrypi:/tmp $
but this is C code and you used C++ tag, strcpy and strcat suppose the receiver have enough space, and if this is false the behavior is undefined. Use the std::string to avoid these problems and more