Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 May 2001 11:43:09 +0100 (BST)
From:      Richard Tobin <richard@cogsci.ed.ac.uk>
To:        Kris Kennaway <kris@obsecurity.org>, Silvestre Malta <smalta@fleximedia.pt>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: function strnlen
Message-ID:  <200105141043.LAA23882@rhymer.cogsci.ed.ac.uk>
In-Reply-To: Kris Kennaway's message of Mon, 14 May 2001 03:05:34 -0700

next in thread | raw e-mail | index | archive | help
> I have no idea what strnlen() could be..

It appears to be a GNU / Linux function.  It does the obvious thing -
returns the length of a length-limited but possibly not
null-terminated string.

Something like this (untested) should do:

size_t strnlen(const char *s, size_t n)
{
    size_t i;

    for(i=0; i<n; i++)
        if(s[i] == 0)
            break;

    return i;
}

-- Richard

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105141043.LAA23882>