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

📄 string.h

📁 Jazmyn is a 32-bit, protected mode, multitasking OS which runs on i386 & above CPU`s. Its complete
💻 H
字号:
#ifndef _STRING_H
#define _STRING_H

#ifdef __cplusplus
extern "C" {
#endif


static inline char* strcpy(char *__dst,const char *__src)
{
	char *p = __dst;
	while(*__src)
	{
		*p = *__src;
		p++;
		__src++;
	}
	*p = '\0';
	return(__dst);
}

static inline int strcmp(const char *__s1, const char *__s2)
{
        int result = 0;
        while((*__s1 == *__s2) && (!result))
        {
                if(!(*__s1) || !(*__s2))
                {
                        result = 1;
                }
		else
                {
                        __s1++;
                        __s2++;
                }
        }
        result = 0;
        if(*__s1 != *__s2)
        {
                result = 1;
                if(*__s1 < *__s2)
                {
                        result = -1;
                }
        }
        return(result);
}

static inline char *strncpy(char *__dst, const char *__src, size_t __count)
{
	char *p = __dst;
	while(__count)
	{
		*p = *__src;
		if(*__src)
		{
			__src++;
		}
		p++;
		__count--;
	}
	return(__dst);
}

static inline int strncmp(const char *__s1, const char *__s2, size_t __count)
{
	int result = 0;
        while((*__s1 == *__s2) && (__count > 1))
	{
		__count--;
                if(!(*__s1) || !(*__s2))
		{
			__count = 0;
		}
		else
		{
		__s1++;
                __s2++;
		}
	}
	result = 0;
        if(*__s1 > *__s2)
	{
		result = 1;
	}
	else
	{
                if(*__s1 < *__s2)
		{
			result = -1;
		}
	}
	return(result);
}

static inline size_t strlen(const char* __s)
{
        size_t slen = 0;
	while(*__s)
	{
		slen++;
		__s++;
	}
	return(slen);
}


static inline char *strcat(char *__s1, const char *__s2)
{
	char *p= __s1 + strlen(__s1);
	while(*__s2)
	{
		*p = *__s2;
		__s2++;
		p++;
	}
	*p = '\0';
	return(__s1);
}

static inline char *strrev(char *__s)
{
	char temp;
	size_t slen;
	char *p1, *p2;
	slen = strlen(__s);
	if(slen > 1)
	{
		p1 = __s;
		p2 = __s + (slen - 1);
		while (p1 < p2)
		{
			temp = *p1;
			*p1 = *p2;
			*p2 = temp;
			p1++;
			p2--;
		}
	}
	return(__s);
}

static inline int toupper(int __c)
{
  if(__c >= 'a' && __c <= 'z') __c = __c - ' ';
  return(__c);
}

static inline char *strupr(char *__s)
{
	char *p = __s;
	while(*p)
	{
		*p = (char)toupper(*p);
		p++;
	}
	return(__s);
}

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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