strncmp.c

来自「一套接口」· C语言 代码 · 共 16 行

C
16
字号
#include <string.h>/*lint -e613strncmp is defined here because some vendors don't implementit, strcmp, or memcmp correctly; they must treat the bytesas unsigned chars.*/int strncmp(const char *s1, const char *s2, size_t n) {	for ( ; n-- > 0; s1++, s2++)		if (*s1 != *s2)			return (unsigned char)*s1 - (unsigned char)*s2;		else if (*s1 == 0)			return 0;	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?