← C-Strings

String Length by Hand

easy

Implement your own version of strlen – count the characters in s up to, but not including, its null terminator. Don’t call the real strlen; the point of this exercise is the loop itself, which every other string exercise in this lesson builds on.

s is const char * for the same reason you saw pointer parameters marked const in the last lesson: this function only reads through s, so its signature should say so.

Your solution

"Run" uses the sample stdin ("hello"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution