Copy the string, the link length, sizes

/*#if 0
#include<stdio.h>

// 1 replication , = CRR ARR
. @ 2 link , ARR = + BRR; Mystrcat ();
// size comparison. 3 , ARR <BRR; Mystrcmp;
// length. 4 ,
// unsafe library functions: Array cross-border.
// des: String object; src: source string

//复制
void Mystrcpy(char des[],char src[])
{
int i;
for(i=0;src[i]!=’\0’;i++)
{
des[i]=src[i];
}
des[i]=’\0’;
printf("%s\n",des);
}

//链接
void Mystrcat(chardes,charsrc)
{
while(*des!= ‘\0’)
{
des++;
}
while( *des++=*src++);
}

The effective length of the string //
int Mystrlen (STR char [])
{
int I;
for (I = 0; STR [I] = '\ 0';! I ++)
{
}
the printf ( "% D \ n-", I );
return I;
}

//比较大小
int Mystrcmp(charstr1,charstr2)
{
while(*str1==*str2&&*str1!=’\0’)
{
str1++;
str2++;
}
return *str1-*str2;
}

int main()
{
char arr[10]=“abcd”;
char brr[10]=“xyz”;
char crr[10];
Mystrcpy(crr,arr);
//不好用
//for(int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
//{
// crr[i]=arr[i];
//}
/printf("%s\n",crr);
Mystrlen(arr);
return 0;
}
#endif
/

Guess you like

Origin blog.csdn.net/wind_waves/article/details/95322558