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

📄 strndup.c

📁 贝叶斯学习算法分类文本。基于朴素贝叶斯分类器的文本分类的通用算法
💻 C
字号:
/* Implementation of strndup() for libc's that don't have it. */#if !HAVE_STRNDUP#include <stdio.h>#include <string.h>#include <sys/types.h>#include <malloc.h>/* Find the length of STRING, but scan at most MAXLEN characters.   If no '\0' terminator is found in that many characters, return MAXLEN.  */size_tstrnlen (const char *string, size_t maxlen){  const char *end = memchr (string, '\0', maxlen);  return end ? end - string : maxlen;}char *strndup (const char *s, size_t n){  size_t len = strnlen (s, n);  char *new = malloc (len + 1);  if (new == NULL)    return NULL;  new[len] = '\0';  return memcpy (new, s, len);}#endif

⌨️ 快捷键说明

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