bsp;*) buf;
buf = (char *) buf + 1;
}
return NULL;
}
memcmp
int memcmp(const void *s, const void *t, int count)
{
assert((s != NULL) && (t != NULL));
while (*(char *) s && *(char *) t && *(char *) s == *(char *) t && count –)
{
s = (char *) s + 1;
t = (char *) t + 1;
}
return (*(char *) s – *(char *) t);
}
memmove
void *memmove(void *dest, const void *src, int count)
{
assert(dest != NULL && src != NULL);
void *address = dest;
while (count –)
{
*(char *) dest = *(char *) src;
dest = (char *) dest + 1;
src = (const char *)src + 1;
}
return address;
}
memset
void *memset(void *str, int c, int count)
{
assert(str != NULL);
void *s = str;
while (count –)
{
*(char *) s = (char) c;
s = (char *) s + 1;
}
return str;
}
strdup
char *strdup(const char *strSrc)
{
assert(strSrc != NULL);
int len = 0;
while (*strSrc ++ != ‘\0′)
++ len;
char *strDes = (char *) malloc (len + 1);
while ((*strDes ++ = *strSrc ++) != ‘\0′)
NULL;
return strDes;
}
strchr_
char *strchr_(char *str, int c)
{
assert(str != NULL);
while ((*str != (char) c) && (*str != ‘\0′))
str ++;
if (*str != ‘\0′)
return str;
return NULL;
}
strchr
char *strchr(const char *str, int c)
{
assert(str != NULL);
for (; *str != (char) c; ++ str)
if (*str == ‘\0′)
return NULL;
return (char *) str;
}
atoi
int atoi(const char* str)
{
int x=0;
const char* p=str;
if(*str==’-’||*str==’+’)
{
str++;
}
while(*str!=0)
{
if((*str>’9′)||(*str<’0′))
{
break;
}
x=x*10+(*str-’0′);
str++;
}
if(*p==’-’)
{
&n |