#include <stdio.h>
size_t strlen_ptr(const char* s) {
if (*s == '\0') return 0;
return (s + 1) - s + strlen_ptr(s + 1);
}
size_t strlen_ptr_diff(const char* s) {
const char* end = s;
while (*end) end++;
return end - s;
}
size_t strlen_recursive(const char* s) {
if (*s == '\0') return 0;
return 1 + strlen_recursive(s + 1);
}
size_t _strlen_helper(const char* s, size_t len) {
if (*s == '\0') return len;
return _strlen_helper(s + 1, len + 1);
}
size_t strlen_wrapper(const char* s) {
return _strlen_helper(s, 0);
}
int main() {
const char* test_str = "Hello, World!";
printf("Method 1: %zu\n", strlen_ptr(test_str));
printf("Method 2: %zu\n", strlen_ptr_diff(test_str));
printf("Method 3: %zu\n", strlen_recursive(test_str));
printf("Method 4: %zu\n", strlen_wrapper(test_str));
return 0;
}