当前位置:网站首页>return 关键字
return 关键字
2022-07-06 14:40:00 【是北豼不太皮吖】
return 关键字
return 用来终止一个函数并返回其后面跟着的值给函数的调用者。
return关键字退出函数运行的同时,给函数返回怎么样的数据?是什么类型的数据?是int类型?char类型?还是void类型?
其实,return返回的数据类型是由函数定义决定的,函数定义的时候,有“返回数据类型”这样的属性,它决定了return返回的数据类型。
return (Val);//此括号可以省略。但一般不省略,尤其在返回一个表达式的值时。
return 可以返回些什么东西呢?看下面例子:
char * Func(void)
{
char str[30];
…
return str;
}
str 属于局部变量,位于栈内存中,在 Func 结束的时候被释放,所以返回 str 将导致错误。
return 语句不可返回指向“栈内存”的“指针”,因为该内存在函数体结束时被自动销毁。
这个语句有问题吗?如果没有问题,那返回的是什么?
return ;
语句是没有问题的。
不过有前提的,是在void类型的函数内才能这样用,作用是结束本函数,此语句后面的语句都不执行了。
边栏推荐
- zabbix 代理服务器 与 zabbix-snmp 监控
- lora同步字设置
- VIP case introduction and in-depth analysis of brokerage XX system node exceptions
- i. Mx6ull build boa server details and some of the problems encountered
- [Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
- HDU 4912 paths on the tree (lca+)
- 第3章:类的加载过程(类的生命周期)详解
- 2022-07-05 stonedb的子查询处理解析耗时分析
- 414. The third largest digital buckle
- 硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
猜你喜欢

在IPv6中 链路本地地址的优势

ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv

Management background --1 Create classification

Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others

GPS from entry to abandonment (XVII), tropospheric delay

Spatial domain and frequency domain image compression of images

About the professional ethics of programmers, let's talk about it from the way of craftsmanship and neatness

Aardio - 不声明直接传float数值的方法

LeetCode刷题(十一)——顺序刷题51至55

GPS from getting started to giving up (16), satellite clock error and satellite ephemeris error
随机推荐
anaconda安装第三方包
Oracle-控制文件及日志文件的管理
AI 企业多云存储架构实践 | 深势科技分享
二叉(搜索)树的最近公共祖先 ●●
图像的spatial domain 和 frequency domain 图像压缩
[MySQL] online DDL details
Shortcut keys in the terminal
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
基於 QEMUv8 搭建 OP-TEE 開發環境
414. The third largest digital buckle
Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
C#实现水晶报表绑定数据并实现打印4-条形码
SQL Server生成自增序号
基于 QEMUv8 搭建 OP-TEE 开发环境
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
The SQL response is slow. What are your troubleshooting ideas?
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
解决项目跨域问题
2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
ZABBIX proxy server and ZABBIX SNMP monitoring