一些函数源码

#include <assert.h>
char* strcpy(char *strDest, const char *strSrc)
{
	assert((strDest != NULL)&&(strSrc != NULL));
	char *address = strDest;
	while ((*strDest++ = *strSrc++) != '\0');	//'\0'is the signal of end
	return address;
}
#include <assert.h>
size_t strlen_L(const char *Deststr)
{
	assert(Deststr != NULL);
	int strlength = 0;
	while(*Deststr++ != '\0')++strlength;	//'\0'is the signal of end
	return strlength;
}
#include <assert.h>
char* strCat(char* strDest, const char* strSrc)
{
	assert(strDest != NULL&&strSrc != NULL);
	char *strtemp = strDest;
	while(*strtemp++ != '\0');
	while((*strtemp++ = *strSrc++) != '\0');
	return strDest;
}


判断字符串中有无相同的字母
bool funct(char *strSrc)
{
	bool bJudge = 0;
	unsigned char usiNum = 0;
	char ctemp;
	char *ptempA = strSrc;
	char *ptempB = strSrc;
	if ((strSrc != NULL) && (strlen(strSrc) > 0))
	{
		while (*strSrc != '\0')
		{
			ctemp = *strSrc;
			while (*ptempA != '\0')
			{
				if (ctemp == *ptempA)
				{	
					++usiNum;		
				}
				if (usiNum > 1)
				{
					return bJudge = 1;
				}
				++ptempA;
			}
			usiNum = 0;
			ptempA = ptempB;
			++strSrc;
		}
	}
	return bJudge;
}
将字符串中的大写字母改写成小写字母
void changeChar(char* strSrc)
{
	if (strSrc != NULL)
	{
		while (*strSrc != '\0')
		{
			switch (*strSrc)
			{
			case 'A':
				*strSrc = 'a';
				break;
			case 'B':
				*strSrc = 'b';
				break;
			case 'C':
				*strSrc = 'c';
				break;
			case 'D':
				*strSrc = 'd';
				break;
			case 'E':
				*strSrc = 'e';
				break;
			case 'F':
				*strSrc = 'f';
				break;
			case 'G':
				*strSrc = 'g';
				break;
			case 'H':
				*strSrc = 'h';
				break;
			case 'J':
				*strSrc = 'j';
				break;
			case 'K':
				*strSrc = 'k';
				break;
			case 'L':
				*strSrc = 'l';
				break;
			case 'M':
				*strSrc = 'm';
			case 'N':
				*strSrc = 'n';
				break;
			case 'O':
				*strSrc = 'o';
				break;
			case 'P':
				*strSrc = 'p';
				break;
			case 'Q':
				*strSrc = 'q';
				break;
			case 'R':
				*strSrc = 'r';
				break;
			case 'S':
				*strSrc = 's';
				break;
			case 'T':
				*strSrc = 't';
				break;
			case 'U':
				*strSrc = 'u';
				break;
			case 'V':
				*strSrc = 'v';
				break;
			case 'W':
				*strSrc = 'w';
				break;
			case 'X':
				*strSrc = 'x';
				break;
			case 'Y':
				*strSrc = 'y';
			case 'z':
				*strSrc = 'z';
			}
			++strSrc;
		}
	}
}




 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值