⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mstrnlen.c

📁 C和指针非常好的一本书.里面的有许多代码可以借鉴.
💻 C
字号:
/*
** Safe string length.  Returns the length of a string that
** is possibly not NUL-terminated.  'size' is the length of the
** buffer in which this string is stored.
*/

#include <string.h>
#include <stddef.h>

size_t
my_strnlen( char const *string, int size )
{
	register size_t	length;

	for( length = 0; length < size; length += 1 )
		if( *string++ == '\0' )
			break;

	return length;
}

⌨️ 快捷键说明

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