C++ 中,实现strcpy的
来源:互联网 发布:程序员修炼之道 mobi 编辑:程序博客网 时间:2024/05/17 09:10
#i
#include <iostream>#include <string>using namespace std;char* str_copy(char* dest,const char* src);int main(){ char* src="this is a test"; cout<<strlen(src)<<endl; //申请内存大小时,需要在源串的长度上加1,以存放\0 char* test=(char*)(malloc(strlen(src)+1)); cout<<sizeof(test)<<endl; str_copy(test,src); if(test!=NULL) { cout<<test<<endl; } else { cout<<"No Enters"<<endl; } free(test); //for console test char c; cin>>c; //end test return 0;};char* str_copy(char* dest,const char* src){ if(dest==NULL) {return NULL;} if(src==NULL || *src=='\0') {return NULL;} char* testTemp=dest; while((*testTemp++=*src++)!='\0'); return testTemp;}
阅读全文
0 0
- C++ 中,实现strcpy的
- 实现C语言中strcpy函数
- 【C语言】strcpy函数的实现
- c/c++ strcpy函数的自己实现
- C 标准库 strcpy 函数的实现
- atoi和strcpy的C语言实现
- C语言strcpy()库函数的实现
- C中不安全的 sprintf 和 strcpy
- C/C++中strcpy函数的用法
- C语言中strcpy函数的理解
- c实现strcpy函数
- C/C++ strcpy实现
- c语言strcpy实现
- C语言实现strcpy
- C语言实现strcpy
- 【C语言】 实现strcpy
- 实现C库函数strcpy
- c语言实现strcpy
- 博主最近学习
- EventBus简单传值
- 心得
- 利用Eclipse JDT ASTRewrite向java源码添加代码
- Android_MVP开发模式登录注册案例
- C++ 中,实现strcpy的
- 什么是比特币挖矿和区块链共识机制?
- 博客
- 逻辑卷管理
- EasyEDA 入坑
- 深度学习
- virtalbox Linux ubntu centos随笔
- android 开发坑点记录
- [leetcode]484.Find Permutation