当前位置:网站首页>Some summary about function
Some summary about function
2022-07-25 22:11:00 【Xiaotang blog】
One : Function call procedure
1. Memory space : Defining formal parameters in a function , When there is no function call , They do not occupy memory storage units , When a function call occurs , function max When the formal parameter of is zero, the memory unit is allocated .
2. The transmission of value : Pass the value corresponding to the argument to the formal parameter , Parameter values for 2, hold 2 Pass to the corresponding formal parameter , Then the formal parameter gets the formal parameter x Get the value 2, Formal parameters get values 3.
3. Worth returning : adopt return Statement to bring the value of the function back to the main function , In the following code , The specified return value is z, This is the of the function max Value ( Also called return value ). perform return Statement brings the return value of this function back to the calling function main, It should be noted that the type of the return value is the same as the function type . Such as max Function is int type , A variable that returns a value z, It's also int type , Two to the same .
#include <stdi#include <stdio.h>
int getMaxFromData(int x,int y){
int sum;
if(x>y)
{
z=x;
}else
{
z=y;
}
return z;
}
int main()
{
int data1;
int data2;
int bigOne;
printf(" Please enter two numbers :\n");
scanf("%d%d%d",&data1,&data2);
bigOne=getMaxFromData(data1,data2);
printf(" The two numbers you enter are :%d,%d\n",data1,data2);
printf(" The largest of these two numbers is %d, The smallest is %d\n",bigOne);
printf("\t Program end !");
return 0;
}
4. Memory free : At the end of the call , The parameter unit is released . Be careful *** The argument unit retains and maintains its original value , There is no change , If when executing a called function , The value of formal parameter changes , Does not change the value of the argument of the calling function . such as : If it's executing max In the process of function ,x and y The value of a 10 and 15, but a and b Still 2 and 3; This is because the real participation parameter is two different storage units .
#include <stdio.h>
int test(int x)
{
printf("test Function x The memory storage address is :%p, Values are :%d\t",&x,x);
int y;
return y;
}
int main()
{
int x;
int y;
printf(" Please enter a number :\n");
scanf("%d",&x);
printf("main Function x The memory storage address is :%p, Values are :%d\n",&x,x);
y=test(x);
return 0;
}
Two : Condition of function call
1. Function has been defined
2. Call library function : If you use library functions , It should be used at the beginning of this document #include The instruction includes the information needed to call the relevant library functions in this document , Columns such as , Instructions that have been used in previous chapters
#include <stdio.h>
among “stdio.h” It's a header file . stay stdio.h The file contains the declaration of input and output library functions . If not “stdio.h” Information in the file , You cannot use functions in the input / output library , Also use the functions in the math library , Should use the :
#include <math.h>
h Is the suffix used in the header file , Indicates that it is a header file ,(header fire)
边栏推荐
- Ansible+cronab batch deployment patrol
- Redis是什么?简述它的优缺点
- YUV420 yuv420sp image format "recommended collection"
- Virtual memory and disk
- Collation of SQL statement exercises
- C语言左值和右值说明[通俗易懂]
- Ts:typera code fragment indentation display exception (resolved) -2022.7.24
- dovecot 设置邮箱quota
- SQL basic statement DQL select and extract DML insert delete
- [Fantan] how to design a test platform?
猜你喜欢

Open source RSS subscriber freshrss

Don't know mock test yet? An article to familiarize you with mock

Jmeter--- set proxy recording request

Summary of function test points of wechat sending circle of friends on mobile terminal

2年功能测试,却感觉自己什么都不会,2022我该何去何从?
![[assembly language 01] basic knowledge](/img/df/d586288b8f41211141bc4e2bca20cf.png)
[assembly language 01] basic knowledge
![[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)](/img/33/08f7b72ce99e07821a1f4b6e594e13.png)
[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)

H5 lucky scratch lottery free official account + direct operation

Square root of X

What should I do if I encounter the problem of verification code during automatic testing?
随机推荐
在进行自动化测试,遇到验证码的问题,怎么办?
如何实现一个App应用程序,限制用户时间使用?
Why does redisv6.0 introduce multithreading?
『Skywalking』. Net core fast access distributed link tracking platform
What have I experienced to become a harder tester than development?
YUV420 YUV420sp 图像格式「建议收藏」
After 2 years of functional testing, I feel like I can't do anything. Where should I go in 2022?
这次龙蜥展区玩的新花样,看看是谁的 DNA 动了?
测试工作不受重视,你换位思考了吗?
JS timer and swiper plug-in
Application of breakthrough thinking in testing work
sql语句练习题整理
Flex layout
关于接口测试你想知道的都在这儿了
What is class loading? Class loading process?
Three ways to allocate disk space
成为比开发硬气的测试人,我都经历了什么?
在腾讯干软件测试3年,7月无情被辞,想给划水的兄弟提个醒...
Summary of function test points of wechat sending circle of friends on mobile terminal
Jmeter--- set proxy recording request