标准库中函数返回值问题
wgzh 2003-08-26 10:52:11 最近关注了一下标准库,发现我们用到的函数很多都有返回值,可是我们却很少用到这些返回值,到底这些值有什么作用呢?
例如: strcpy原型:
char *strcpy(char *strDestination,const char *strSource);
问题:通过strcpy()已经把strSource中的内容拷贝到strDestination中,为何还需要返回char *的返回值呢?
char *strcpy(char *strDestination,const char *strSource)
{
assert( strDestination != NULL && strSource != NULL );
while( *strSource != '\0' )
{
*strDestination = *strSource;
strDestination++;
strSource++;
}
*strDestination = '\0';
return strDestination;
}