标准库中函数返回值问题

wgzh wgzh 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近关注了一下标准库,发现我们用到的函数很多都有返回值,可是我们却很少用到这些返回值,到底这些值有什么作用呢?
例如: 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;
}

...全文
评论 6
收藏 已收藏
分享
返回顶部
wgzh
工具平台和程序库 24,849 成员 27,328 内容