当前位置:网站首页>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类型的函数内才能这样用,作用是结束本函数,此语句后面的语句都不执行了。
边栏推荐
- Oracle Performance Analysis 3: introduction to tkprof
- 基於 QEMUv8 搭建 OP-TEE 開發環境
- What are the interface tests? What are the general test points?
- Applet system update prompt, and force the applet to restart and use the new version
- 小程序系统更新提示,并强制小程序重启并使用新版本
- GPS from getting started to giving up (12), Doppler constant speed
- 2021 geometry deep learning master Michael Bronstein long article analysis
- Notes de développement du matériel (10): flux de base du développement du matériel, fabrication d'un module USB à RS232 (9): création de la Bibliothèque d'emballage ch340g / max232 SOP - 16 et Associa
- 每日一题:力扣:225:用队列实现栈
- Barcodex (ActiveX print control) v5.3.0.80 free version
猜你喜欢
HDR image reconstruction from a single exposure using deep CNNs阅读札记
[leetcode daily clock in] 1020 Number of enclaves
GNN,请你的网络层数再深一点~
The SQL response is slow. What are your troubleshooting ideas?
GPS from entry to abandonment (XVII), tropospheric delay
[10:00 public class]: basis and practice of video quality evaluation
How does the uni admin basic framework close the creation of super administrator entries?
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
随机推荐
墨西哥一架飞往美国的客机起飞后遭雷击 随后安全返航
[MySQL] online DDL details
Management background --2 Classification list
Xiaoman network model & http1-http2 & browser cache
qt quick项目offscreen模式下崩溃的问题处理
Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode
Crawler obtains real estate data
MariaDB database management system learning (I) installation diagram
Lora sync word settings
GPS from getting started to giving up (12), Doppler constant speed
中国固态氧化物燃料电池技术进展与发展前景报告(2022版)
微信红包封面小程序源码-后台独立版-带测评积分功能源码
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
SQL Server生成自增序号
anaconda安装第三方包
Problems in the process of opencv300 cmake generating project
lora同步字设置
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
HDR image reconstruction from a single exposure using deep CNNs阅读札记
Unity3D学习笔记6——GPU实例化(1)