Also, while it may seem a bit difficult now, it is a lot safer to forget about strcpy and strcat and use their friends - strncpy and strncat. While big strings can mitigate the problem, the versions that do not take a count of characters can and will try to copy more stuff than you have space for.
Code:
char name[16];
char string2[40];
int used = 0;
int length = 0;
strncpy(name, "Mark", sizeof name - 1);
strncpy(string2, "My name is ", sizeof string2 - 1);
used = strlen(string2);
if (strlen(name) + used < sizeof string2)
{
strncat(string2, name, sizeof string2 - used - 1);
length = strlen(string2);
printf("The length of this string >>%s<< is %d characters \n", string2, length);
}
else
{
/* string2 may be truncated! */
}
This tip is especially important for user input that you glue into a string, and - though it may seem like a lot of work - it is basic safety.