You have undefined behaviour, because you're calling strlen with a pointer to a character array that is not null-terminated (c). You need to pass null-terminated strings for this to work. This is an example, fixing that and some other errors, and including the required headers:
You have undefined behaviour, because you're calling
strlenwith a pointer to a character array that is not null-terminated (c). You need to pass null-terminated strings for this to work. This is an example, fixing that and some other errors, and including the required headers: