御剑飞翔
yjfx77
全部博文(33)
高级bash脚本编程(1)
2010年(23)
2009年(10)
疾风劲松
baiyaj
shell_1
135lihui
weisuen
mrchen11
arkwind
ljwd1000
千寻O白
分类: C/C++
2009-12-16 22:41:30
strlen:
int strlen(const char* str) { int i=0; while(*str++) i++; return i; }
strcmp:
int strcmp( const char *p1 , const char *p2 ) { register const unsigned char *s1 = (const unsigned char *) p1; register const unsigned char *s2 = (const unsigned char *) p2; unsigned char c1, c2; do { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0') return c1 - c2; } while (c1 == c2); return c1 - c2; }
int strcmp( const char *p1 , const char *p2 )
{
register const unsigned char *s1 = (const unsigned char *) p1;
register const unsigned char *s2 = (const unsigned char *) p2;
unsigned char c1, c2;
do {
c1 = (unsigned char) *s1++;
c2 = (unsigned char) *s2++;
if (c1 == '\0')
return c1 - c2;
} while (c1 == c2);
}
上一篇:mysql使用小结
下一篇:vi中的字符串替换
登录 注册