strcpy函数
来源:互联网 发布:短信网关软件 编辑:程序博客网 时间:2024/06/18 16:30
#include<stdio.h>#include <assert.h> void myStrcpy(char* Dest, const char *Src){ assert((Dest!= NULL)&&(Src!=NULL)); while((*Dest = *Src)!='\0') { Dest++; Src++; }}int main(){ char dest[] = "helloworld";//注意 char* src = "hello"; myStrcpy(dest, src); printf("%s",dest); return 0;}
注意:在第15行中,我们用的是字符数组,因为如果用字符指针的话,字符常量存放在常量区,指针会指向这个地址,不能通过修改指针指向内容修改字符串。如果用字符数组的话,会把“helloworld“内容复制到数组中去,可以被修改。
strcpy函数原型:
char *strcpy(char *Dest , const char *Src){assert((Dest != NULL) && (Src != NULL));char *address = Dest;while((*Dest++ = *Src++) != '\0')NULL;return address;}
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy()函数
- strcpy() 函数
- strcpy函数
- strcpy函数
- Strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数 .
- strcpy函数
- strcpy函数
- strcpy 函数
- strcpy函数
- iOS开源:表格视图GMGridView
- c++面试题连接
- Xcode4中xib绑定的原理
- 阅读笔记(1)
- C++函数指针
- strcpy函数
- 编写类String的构造函数、析构函数和赋值函数
- 静态链表
- 如何混淆Android项目代码(ProGuard),防止反编译
- strlen函数,strcat函数,strcpy函数,strncpy函数,strcmp函数
- IOS成长之路-使用xib界面与和代码相关联的方法
- Ubuntu tar解压出错解决方案
- VC中如何定义一个让所有源程序都能用的全局变量(对象)
- Linux Shell(bash) 输出到文本、重定向技巧