Which condition must hold for strcat(dest, src) to work correctly?
Correct answer A. dest must hold a null-terminated string and have room for both strings plus one null byte
strcat finds the null terminator of dest and copies src, including its null, from that point. So dest must already be a valid string and its array must be large enough for strlen(dest) + strlen(src) + 1 bytes. strcat does no bounds checking, and overflowing dest is undefined behaviour, a classic buffer overflow. The two strings must also not overlap.
Answer checked How we write and check questions
Discussion