strcpy函数执行解析
来源:互联网 发布:mac休眠后无法唤醒 编辑:程序博客网 时间:2024/06/07 19:29
实参传递给形参的过程是将实参拷贝一份传递给形参。
//============================================================================// Name : Pointer2.cpp// Author : xie// Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//============================================================================#include <iostream>using namespace std;void stringcpy(char *des,char *source);int main() {char str[]="fuckyou";char str1[10];printf("str is %d\n",str);printf("&str is %d\n",&str);stringcpy(str1,str);return 0;}/** * 形参和实参的地址不一样。将字符指针str拷贝一份传送给source * str存了字符串的首地址2293608,将2293608传给source,source所在的地址 * 为2293556,即内存单元2293556中存放了字符串首地址2293608,函数执行完以后 * source指向字符串的尾部,即2293556中存放的是2293608+source.length() * 但str中依然存放的是2293608.副作用没有影响实参str。 */void stringcpy(char *des,char *source) {printf("source is %s\n",(char *)2293609);printf("source is %d\n",source);printf("&source is %d\n",&source);while((*des++ = *source++) !='\0');}
运行结果如下:
str is 2293608
&str is 2293608
source is uckyou
source is 2293608
&source is 2293556
- strcpy函数执行解析
- strcpy函数解析~
- strcpy函数解析
- strcpy函数解析
- strcpy 字符串拷贝函数解析
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy()函数
- strcpy() 函数
- strcpy函数
- strcpy函数
- Strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- strcpy函数
- Mybatis - 全站代码 - 中文文档下载 - api文档下载
- hadoop-eclipse-plugin的正确使用(对应0.20.1版本)
- Android的视频通话的Java代码
- Python中Function(函数)和methon(方法)
- 顺序栈的基本操作实现
- strcpy函数执行解析
- 数据结构之Status
- matplotlib手册之图装饰
- 配置tomcat与solr
- MyEclipse6.5 使用快捷键卡死
- 数据挖掘
- x264_mb_predict_mv_ref16x16 函数分析
- 静态库和动态库的优缺点
- 关于base64的问题