当前位置:网站首页>Section 7 - structures
Section 7 - structures
2022-06-13 04:47:00 【Stretch the curtain with the wind】
Catalog
1.1 Basic knowledge of structure
1.4 Structure variable definition and initialization
2. Access to structure members
1. Declaration of a structure
1.1 Basic knowledge of structure
structure Is a collection of values , These values are called member variables . Each member of a structure can be a variable of a different type
and
Array Is a collection of the same elements
The objects in life are complex
Structure is used to describe complex objects
1.2 Statement of structure
struct tag{member-list;} variable-list;
There are two ways to create structure variables :
The first way to create it :
The second way to create :
The difference between the two structure variables :
The structure variables created by the first creation method are local
The structure variables created by the second creation method are global
1.3 Type of structure member
The members of a structure can be scalars 、 Array 、 The pointer , Even other structures .
1.4 Structure variable definition and initialization
2. Access to structure members
3. Structural parameters
3.1. Value transfer call
notes : Structural variables are generally large , If you make a value passing call in the structure , A formal parameter is a temporary copy of an argument , In this case, the waste of space is serious
3.2. Address call
notes : The formal parameter pointer variable of the address transfer call stores the address of the actual parameter , It only needs 4/8 Bytes
3.3. summary
notes :
1. Any function call will apply for space in the stack area
2. The stack area will give main Function allocates a space , Access some... In this space main Local variables in functions . When a function is called , First, transfer parameters , Will be main A copy of the arguments in the function , The memory space of the copy is allocated in main Above the space occupied by the function , Then allocate a part of the memory space above the formal parameter variable to the function .
3. Similar to the stack in the data structure : Insert elements at the top of the stack , Delete elements at the top of the stack . Inserting elements at the top of the stack is called pressing the stack , Deleting elements at the top of the stack is called out of the stack . When a function passes parameters, it is similar to function stack pressing .
When a function passes parameters , Parameters need to be stacked .If you pass a structure object , The structure is too large , The system overhead of parameter stack pressing is relatively large , So it can lead to performance degradation .therefore : When structures transmit parameters , To transfer the address of the structure .
边栏推荐
- Go/golang connection to database
- Vercel 使用 HTTP 缓存
- Webpack system learning (VIII) how contenthash can prevent browsers from using cache files
- JS to realize the conversion between string and array and an interview question
- 一致性哈希的简单认识
- 2022 oxidation process operation certificate examination question bank and simulation examination
- PowerDesigner easy to use
- General communication protocol for industrial Internet
- Explain the differences and usage scenarios between created and mounted
- 如何只用4步,实现一个自定义JDBC驱动?
猜你喜欢
How to use redis
Createanonymousthreadx passes parameters to anonymous threads
Normal distribution (Gaussian distribution)
Win8.1和Win10各自的優勢
Several methods of identifying equivalent circuit of circuit drawing
[JS solution] leedcode 200 Number of islands
Explain the role of key attribute in V-for
LeetCode第297场周赛(20220612)
自动评教脚本使用的配置
josephus problem
随机推荐
Analysis on the usage, response and global delivery of provide/inject
Gets or sets the content in an object
CreateAnonymousThreadX给匿名线程传递参数
Solution to sudden font change in word document editing
Must know must know -c language keywords
正态分布(高斯分布)
Internet people a few years ago vs Internet people today
Serial communication learning
Little C's Notepad
Powershell 加域 Add-Computer模块
Red Treasure Book Reading Notes (continuously updated)
SS selector
Implementation of homepage header function in PHP development blog system
Explain the differences and usage scenarios between created and mounted
小C的记事本
Tita绩效宝:远程一对一面谈的问题
Analysis of the principle of V-model and its application in user defined components
第三方评论插件
Tita performance treasure: remote one-on-one discussion
Nodejs parsing get request URL string