当前位置:网站首页>C language linked list points to the next structure pointer, structure and its many small details
C language linked list points to the next structure pointer, structure and its many small details
2022-06-24 03:56:00 【Good pie notes】
There are quite a few students studying C In the process of language , When you learn the linked list, you can't go around , It's too late to get to the point .
This paper attempts to interpret the linked list creation algorithm from scratch from the perspective of Xiaobai .
Before formally studying the linked list , Let's start with the structure . It's like a pointer , A structure is also a data type , But this data type can store complex data of multiple attributes , You need to define the type before using .
Its definition form is very simple :struct name { List of members ;}; For example, for a student , He can be named 、 Gender 、 Student number 、 Grades and so on , And these data can be in strings respectively 、 character 、 integer array 、float Type of data storage .
So we can define a student's structure , It contains all his attributes , Just note that we only define a data type , If you want to apply for a storage unit from memory, you should continue to declare variables .
Then let's talk about its use , Variables can be used , The premise is that you can express it . For simple data types ( such as int), We can peel the onion and add the structure name '.' The way to put it “ spot ” come out .
Here's another small detail , Is the processing of strings . String cannot be assigned , Only character arrays or character copy functions can be used strcpy() Etc . The name of the string represents the first address , Is the address constant , Constant cannot be assigned .
After defining the structure type, the system will not allocate units , Only when variables are defined will the system allocate units . Of course, you can also define structure arrays , The numbers in brackets indicate the length , The size of each unit is the length specified by the structure type .
We mentioned earlier that , If you want to operate on a certain section of memory, the premise is 【 Express the variable 】.
For structure pointers , You can look at the name and know the meaning : This is a pointer , Only the address stored in this pointer is the address of a structure variable .
For structure pointers , Members accessing the structure variable it points to can use the value taking operator *, such as struct (*stu).name. Of course , The way we prefer to use in practice is the arrow way :struct stu->name.
Let's look at something interesting :++p->age、(++p)->age、(p++)->age、p++->age. Actually C Similar expressions can be found everywhere in the language , Just keep your head clear when you see it , It is easy to pay attention to the operation priority and self increment processing , The reader can deduce .
stay C In language , If you want to use structural variables, you must mark them in front of you struct, To indicate that this is a structural variable ( Although in .cpp The file supports ellipsis ), This way of writing often makes the code verbose , So programmers often prefer to use alias keywords typedef.
You can use keywords at the beginning of the structure struct, In this way, the structure type or the corresponding pointer type can be aliased , In the process of use, there will be one less struct, Why not do it !
Just for beginners , It may be difficult to understand how to alias structure pointer types . Here we just need to treat it as an equivalent replacement , After aliasing the structure pointer, the pointer will be marked * Hide it , But in actual use, we should always pay attention to , This is still a pointer .
边栏推荐
- Use lightweight application server to automatically download and upload to onedrive
- Dialogue with Google technical experts: soundstream is expected to be used for general audio coding in the future
- MySQL stored procedure + function
- Differences between EDI and VMI
- A problem of testing security group access in windows10
- 开源一款监控数据采集器,啥都能监控
- Rasa 3. X learning series -rasa 3.2.0 new release
- How EDI changes supply chain management
- How to avoid man in the middle attack (mitm)
- Black hat SEO actual combat search engine snapshot hijacking
猜你喜欢

Black hat SEO practice: General 301 weight PR hijacking

Clickhouse (02) Clickhouse architecture design introduction overview and Clickhouse data slicing design

【代码随想录-动态规划】T392.判断子序列

Yuanqi forest pushes "youkuang", and farmers' mountain springs follow the "roll"?

Installation of pytorch in pycharm
![[numpy] numpy's judgment on Nan value](/img/aa/dc75a86bbb9f5a235b1baf5f3495ff.png)
[numpy] numpy's judgment on Nan value

618大促:手机品牌“神仙打架”,高端市场“谁主沉浮”?

Ar 3D map technology

JVM调优简要思想及简单案例-怎么调优

Modstartcms enterprise content site building system (supporting laravel9) v4.2.0
随机推荐
The importance of the computer room to the stable operation of the server
Building RPM packages - spec Basics
Tencent cloud console work order submission Guide
Use the fluxbox desktop as your window manager
How to bypass CDN to get web pages? How many options are available?
LeetCode 129. Find the sum of numbers from root node to leaf node
Pine Script脚本常用内容
3. go deep into tidb: perform optimization explanation
hprofStringCache
Several key tools for cloud native implementation
In the post epidemic era, "cloud live broadcast" saves "cloud cultural tourism"?
Typera cooperates with picgo to upload pictures to its own server with one click and obtain external links at the same time
hprofStringCache
浅谈游戏安全 (一)
Tens of millions of Android infected with malicious virus and Microsoft disabled a function of Excel | global network security hotspot on October 9
NLP task summary introduction and understanding
Ar 3D map technology
13. Tencent cloud IOT device side learning - data template function and Implementation
Brief ideas and simple cases of JVM tuning - how to tune
Iguard6.0 - appropriate website protection system