1.拷贝字符串到目标字符串
char *strcpy(char *strDestination, const char *strSource);
复制源串strSource到目标串strDestination所指定的位置, 包含NULL结束符. 不能处理源串与目标串重叠的情况.
函数返回strDestination值.
char *strcpys(char *strDes, const char *strSrc)
{
assert((strDes != NULL) && (strSrc != NULL)); //assert用以检测是否为空,通过assert处理异常来返回NULL !!!!觉得这里好像这里有错,如果没有初始化呢、、??
char *address = strDes;
while ((*strDes ++ = *strSrc ++) != '\0')
NULL;
return address;
}
nt strcmp(const char *string1, const char *string2); 比较字符串string1和string2大小. 返回值< 0, 表示string1小于string2; 返回值为0, 表示string1等于string2; 返回值> 0, 表示string1大于string2.
int strcmp(const char *s, const char *t)
{ assert(s != NULL && t != NULL);
while (*s && *t && *s == *t)
{ ++ s; ++ t; }
return (*s - *t);
}