Finding the number of bytes written in a larger array
You need to keep track of that yourself.

For example, if you're using the array as a circular buffer, you would have additional variables that hold the index values for the "head" (newest) and "tail" (oldest) valid values. You advance the "head" index whenever you add a byte, and advance the "tail" whenever you remove one.

The difference between the "head" and "tail" indices (modulo the size of the array) tells you how many bytes are valid.