There are a couple of ways to do this.
The first is to always make sure the end of your array has a termination character (such as null or an empty string "")
Then when you loop through the array have the termination criteria be i == NULL or i == ""
The other way is to keep track of the length of your array from the beginning of your program. For example, declare your array to be a specific length at the very start of your program or procedure.
There is no built in length() function for C/C++ arrays