strlen:
// strlen
#include <stdio.h>
size_t Strlen(const char *s)
{
const char *p = NULL;
for (p = s; *p != '\0'; ++p)
;
return p - s;
}
int main(int argc, char **argv)
{
char buffer[61] = "abc";
int len = Strlen( buffer );
printf( "'%s' is %d characters long\n", buffer, len );
return 0;
}
一直觉得size_t这个类型神乎其神,反正它是无符号整型,具体搞不清,但size_t是有它的用处的,别试图用int之类的代替它!