有趣的字符串copy函数
2022-09-11 11:13 钟铧若岩 阅读(31) 评论(0) 编辑 收藏 举报1 #include <iostream> 2 #include <iomanip> 3 #include <string> 4 using namespace std; 5 double power(double x,int n); 6 char * mycopy(char *dest, const char * src) 7 { 8 if(src == NULL || dest ==NULL) 9 return NULL; 10 if(src == dest) 11 return NULL; 12 char *temp = dest; 13 cout << "src = " << src << endl; 14 while((*dest++ = *src++)!= '\0'){} 15 16 cout <<"temp = "<<temp<<endl; 17 18 return temp; 19 } 20 21 int main() 22 { 23 cout <<"hello"<<endl; 24 25 char src[10] = "wfg"; 26 char dest[10]; 27 mycopy(dest,src); 28 cout << "dest = "<< dest <<endl; 29 return 0; 30 31 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?