I have read that use of strlen is more expensive than such testing like this:
strlen
We have a string x 100 characters long.
x
I think that<
The first code checks length of x in every iteration of i and it takes O(n) to find the last 0, so it takes O(n^2), the second case is O(n)