#include <stdio.h>
#define pointer
//#define array

size_t my_strlen(const char* str) {
    
#ifdef pointer
    size_t length = 0;
    while (*str != '\0') {
        length++;
        str++;
    }
    return length;
#endif

#ifdef array
    int i;
    for(i=0; str[i]!='\0'; i++){
        
    }
    return i;
#endif
}

int main() {
    char str[] = "Hello, world!";
    size_t length = my_strlen(str);
    printf("The length of the string is %zu characters\n", length);
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: