当前位置:网站首页>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类型的函数内才能这样用,作用是结束本函数,此语句后面的语句都不执行了。
边栏推荐
- GNN, please deepen your network layer~
- What are the interface tests? What are the general test points?
- Anaconda installs third-party packages
- 小程序系统更新提示,并强制小程序重启并使用新版本
- 3DMax指定面贴图
- 【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
- Attack and defense world ditf Misc
- Mise en place d'un environnement de développement OP - tee basé sur qemuv8
- Mongodb (III) - CRUD
- MariaDB database management system learning (I) installation diagram
猜你喜欢

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

Assembly and interface technology experiment 5-8259 interrupt experiment

PVL EDI project case

Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices

2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行

GNN,请你的网络层数再深一点~

剪映+json解析将视频中的声音转换成文本

GPS from getting started to giving up (XV), DCB differential code deviation

C # réalise la liaison des données du rapport Crystal et l'impression du Code à barres 4

网络基础入门理解
随机推荐
MySQL数据库基本操作-DML
GPS from entry to abandonment (XVII), tropospheric delay
Crawler obtains real estate data
LeetCode刷题(十一)——顺序刷题51至55
中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)
GD32F4XX串口接收中断和闲时中断配置
UNI-Admin基础框架怎么关闭创建超级管理员入口?
OpenCV VideoCapture. Get() parameter details
How do I write Flask's excellent debug log message to a file in production?
414. The third largest digital buckle
数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据
QT | UDP broadcast communication, simple use case
GPS from getting started to giving up (12), Doppler constant speed
做接口测试都测什么?有哪些通用测试点?
What a new company needs to practice and pay attention to
Support multiple API versions in flask
HDR image reconstruction from a single exposure using deep CNNs阅读札记
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
Codeforces Round #274 (Div. 2) –A Expression
lora同步字设置