看看我写的
int Strlen(char *arr)
{
int count = 0;
while(*arr)
{
++count;
++arr;
}
return count;
}
char * Strcpy(char *strDes, char *strSor)
{
while ( !( (*strDes==0) && (*strSor==0) ) )
{
++strDes;
++strSor;
}
strDes = '\0';
return strDes;
}
int Strcmp(char *string1, char *string2 )
{
while( *string1 == *string2 )
{
if(*string1 == '\0')
{
return 0;
}
string1++;
string2++;
}
return (*string1 - *string2);
}
int Strncmp(char *string1, char *string2, int size )
{
int count = 0;
while(count< size)
{
if(string1[count] != string2[count])
{
return string1[count]- string2[count];
}
++count;
}
return 0;
}
char * Strncpy(char *strDes, char *strSor , unsigned int size )
{
unsigned int count = 0;
while( (*strDes = *strSor ) && ( count < size ) )
{
++strDes;
++strSor;
++count;
}
strDes = '\0';
return strDes;
}
char * Strcat( char *strDes, char *strSor )
{
char *dest = strDes;
dest = dest + Strlen(strDes);
Strcpy(dest,strSor);
return strDes;
}
[此贴子已经被作者于2006-11-13 9:51:12编辑过]