Kodewick
Start learning →
Starter←→0 / 70

Icing letters

#038StarterStringsLoops3 min

The birthday cake gets a message in icing, one squeeze per character (spaces too). Write name_length(name) to count the characters in name without using strlen. An empty string gives 0.

Examples
name_length("Happy Birthday")→14
name_length("")→0
The functionint name_length(const char *name)
main.c
int name_length(const char *name) {
    int n = 0;
    for (int i = 0; name[i] != '\0'; i++) {
        // your code here: for each character you pass, add 1 to n
    }
    return n;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.