How can I go about concatenating two arrays of char(ex. char boy[] and char girl[]) so that the contents of girl is attached to the contents of boy?

call strcat() from string.h header file. But be careful -- the desgination character array has to be large enough to hold both strings, and it can not be a pointer into read-only memory (e.g. string literals).

char boy[] = "Harry";
char* boy = "Harry"; // <<<< this is also wrong because its a string literal
char girl[] = "Mary";

The above can not be concantinated because boy is not large enough to hold b oth boy and girl.

The correct solution is like this

char boy[80] = "Harry";
char girl[] = "Mary";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.