|
int * memset(char * p,char val,int m_length)
{
if (p==NULL||m_length<0) //判断指针是否初始化
{prinf("ERROR!");
return(0); //赋值失败返回"0"
}
else
while(m_length>0)
*p++=val,m_length--;
return(1); //赋值成功返回"1"
}
int strcmp(char *s1,char *s2) //相当返回 0; s1>s2 返回 1; s1<s2 返回-1;
{ while(*s1==*s2&&*s1!='\0'&&*s2!='\0')
s1++,s2++;
if(*s1=='\0'&&*s2=='\0')
return(0);
else if(*s1=='\0')
return(-1);
else if(*s2=='\0')
return(1);
else
{if(*s1>*s2)
return(1);
else
return(-1);
}
}
char * strcpy(char * s1, char * s2)
{ char * temp = s1;
while(*s2!='\0')
*temp++ = *s2++;
return(s1);
}
[ 本帖最后由 NODDY820 于 2007-7-29 17:04 编辑 ] |
|