C++程序  |  14行  |  159 B

/*
 * strnlen()
 */

#include <string.h>

size_t strnlen(const char *s, size_t n)
{
    const char *ss = s;
    while (n-- && *ss)
	ss++;
    return ss - s;
}