函数返回局部变量地址
来源:互联网 发布:股权投资 知乎 编辑:程序博客网 时间:2024/06/06 19:26
示例:
#include <stdio.h>#include <stdlib.h>#include <string.h>const char *get_str1();const char *get_str2();int *add(int a, int b);int main() {const char *str1 = get_str1();const char *str2 = get_str2();int *sum = add(2, 3);printf("str1: %s.\n", str1);printf("str2: %s.\n", str2);printf("sum: %d.\n", *sum);return EXIT_SUCCESS;}const char *get_str1() {//此处为返回静态内存的地址const char *str = "Hello world1";return str;}const char *get_str2() {//此处为返回局部变量的地址const char str[] = "Hello world2";return str;}int *add(int a, int b) {//此处为返回局部变量的地址int ret = a + b;return &ret;}
- 函数返回局部变量地址
- 函数返回局部变量地址
- 局部变量与函数返回地址
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数返回局部变量
- 函数局部变量返回
- 函数返回局部变量
- 函数返回局部变量
- linux升级python
- OracleDBconsoleorcl服务无法启动的原因及解决思路
- 【PB】动态添加数据窗口列中下拉列表的内容
- 硕士论文查重原理与快速通过的七大方法
- C++回调函数问题的解决方案
- 函数返回局部变量地址
- 安卓常用控件一
- poj 1679 prim
- 黑马程序员四、String 类
- [最大流]poj 2112 ptimal Milking#floyd+二分+最大流
- 搜索题目推荐及解题报告
- 分本分类与聚类 笔记
- zoj 3643 Keep Deleting
- localhost与127.0.0.1的区别