/* * strnlen() - Return the minimum of the length of the * NUL-terminated string, or the given maximum. * * Dan Cross */ #include #include size_t strnlen(const char *str, size_t maxsize) { size_t n, len; for (n = maxsize, len = 0; n > 0 && str[len] != '\0'; n--) len++; return(len); }