mystring.h

来自「自己做的常用库和实现的数据结构。public domain.」· C头文件 代码 · 共 65 行

H
65
字号
/* String handlers. * * Written by Cyril Hu (cyrilhu@gmail.com), public domain. */#ifndef _MYSTRING_H_#define _MYSTRING_H_#include "my.h"void 	*mymemcpy	(void *dst, const void *src, size_t n);char 	*mystrcpy	(char *dst, const char *src);char 	*mystrncpy	(char *dst, const char *src, size_t n);char 	*mystrcat	(char *dst, const char *src);char 	*mystrncat	(char *dst, const char *src, size_t n);int   	 mystrcmp	(const char *s1, const char *s2);int   	 mystrncmp	(const char *s1, const char *s2, size_t n);int   	 mymemcmp	(const void *s1, const void *s2, size_t n);void 	*mymemchr	(const void *src, int c, size_t n);char 	*mystrchr	(const char *src, int c);char 	*mystrrchr	(const char *src, int c);size_t 	 mystrcspn	(const char *src, const char *sub);char 	*mystrpbrk	(const char *src, const char *sub);size_t	 mystrlen	(const char *src);char	*mystrstr	(const char *src, const char *sub);void	*mymemset	(void *src, int c, size_t n);/* Yet another strcpy(), [begin, end] points to sequential location in ONE source. */char *yastrcpy(char *dst, const char *begin, const char * const end);/* Place source string in revsered order. */char *strrev(char *src);/* Locate the last occurence of matching substring in given source string. */char *strrstr(const char *src, const char *sub);/* Count how many ASCII words in given string, * including compound word with joint dash symbol(s). */size_t scntwd(const char *src);/* Count how many ASCII words in given open stream, * including compound word with joint dash symbol(s). */size_t fcntwd(FILE *fp);/* Check for identical chars in given string, * return true if yes, false if no or string empty. */bool isdupchr(const unsigned char *src);/* Substitute all matching substr(s) with replstr in given source string, * which is supposed to be big enough to hold all changes; * if replace string is empty, it means delete all matching substring(s). */char *strsstr(char *src, const char *sub, const char *repl);/* Format source stream into n byte wide, stream must be "rb+" or "r+b"; * fp will be rewinded when done; returns 0 on success, -1 on failure. */int ffmt(FILE *fp, size_t n);#endif /* _MYSTRING_H_ */

⌨️ 快捷键说明

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