#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;
}
}
}