当前位置:网站首页>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 .
边栏推荐
- php开发博客系统的首页头部功能实现
- shell变量学习笔记
- 2022 oxidation process operation certificate examination question bank and simulation examination
- Trust programming - linked lists: use struct to implement linked lists, use heap to merge K ascending linked lists, and customize display
- Blockly learning ----2 Code generation, grid, scaling, events, storage
- PHP syntax
- Your one-on-one meetings are inefficient. You can do this!
- JS, how to add grid style
- Infinite cycle scrolling code Alibaba international station store decoration code base map scrolling black translucent display effect custom content decoration code full screen display
- php 18 首页的文章列表功能实现
猜你喜欢

A simple understanding of consistent hash

C disk lossless move file

Normal distribution (Gaussian distribution)

Redis master-slave replication, sentinel mode, cluster
![[chapter 67 of the flutter problem series] the solution to the problem that the get plug-in cannot jump to the route twice in the dialog pop-up window in flutter](/img/59/0d95619ee3bba1f8992d90267d45c2.png)
[chapter 67 of the flutter problem series] the solution to the problem that the get plug-in cannot jump to the route twice in the dialog pop-up window in flutter
![[leetcode]- binary search](/img/7f/7d1f616c491c6fb0be93f591da6df1.png)
[leetcode]- binary search

Cesium:cesiumlab makes image slices and loads slices

约瑟夫问题

2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY

Several methods of identifying equivalent circuit of circuit drawing
随机推荐
It's the Caesar code. (*‘▽‘*)*
2022 oxidation process operation certificate examination question bank and simulation examination
Little C's Notepad
[LeetCode]-二分查找
Go/golang connection to database
Red Treasure Book Reading Notes (continuously updated)
Construction problem of D Xiaohong
一致性哈希的简单认识
JS, how to add grid style
Go scheduled task cron package usage
是“凯撒密码”呀。(*‘▽‘*)*
CreateAnonymousThreadX给匿名线程传递参数
2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
第三方评论插件
Li Kou brush question 647 Palindrome substring
135. distribute candy
Promise processing JS multithreads get the same processing result after all the results are obtained
A simple understanding of consistent hash
Converting MySQL data to PostgreSQL with Navicat
2022年建筑架子工(建筑特殊工种)特种作业证考试题库及在线模拟考试