博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
strcpy()的实现
阅读量:4695 次
发布时间:2019-06-09

本文共 493 字,大约阅读时间需要 1 分钟。

#include 
#include
char* strcpy(char *strDest,char *strSrc){ assert((strDest!=NULL)&&(strSrc!=NULL)); if(strDest==strSrc) return strDest; char *pDest=strDest; char *pSrc=strSrc; while(*pDest++=*pSrc++); *pDest='\0'; return strDest;}int main(){ char *p1="hello"; char p2[40]; strcpy(p2,p1); printf("%s",p2); return 0;}

至于为什么返回类型是char*,就是为了方便,链式表达式。

转载于:https://www.cnblogs.com/sherkey/archive/2013/02/27/2935856.html

你可能感兴趣的文章
【模式识别与机器学习】——SVM举例
查看>>
【转】IT名企面试:微软笔试题(1)
查看>>
IO流入门-第十章-DataInputStream_DataOutputStream
查看>>
DRF的分页
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
python:open/文件操作
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
tomcat 和MySQL的安装
查看>>
git常用操作
查看>>
京东SSO单点登陆实现分析
查看>>
u-boot启动第一阶段
查看>>
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>
C#中StreamReader读取中文出现乱码
查看>>
使用BufferedReader的时候出现的问题
查看>>
批处理文件中的路径问题
查看>>
hibernate出现No row with the given identifier exists问题
查看>>