当前位置:网站首页>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 .
边栏推荐
- LeetCode 2006. Number of pairs whose absolute value of difference is k
- Technical dry goods - how to use AI technology to accurately identify mining Trojans
- Recording a summary of frequently asked questions
- Several key tools for cloud native implementation
- Web penetration test - 5. Brute force cracking vulnerability - (1) SSH password cracking
- [numpy] numpy's judgment on Nan value
- The collection method of penetration test, and which methods can be used to find the real IP
- Modstartcms enterprise content site building system (supporting laravel9) v4.2.0
- [Tencent cloud update] against 11.11! Here comes the 1.1% discount for enterprises!
- Difference and efficiency between get winevent and get eventlog
猜你喜欢

SQL注入绕过安全狗思路一

halcon知识:区域(Region)上的轮廓算子(2)

Flutter series: offstage in flutter

你了解TLS协议吗?
![[numpy] numpy's judgment on Nan value](/img/aa/dc75a86bbb9f5a235b1baf5f3495ff.png)
[numpy] numpy's judgment on Nan value

Installation of pytorch in pycharm

ModStartCMS 主题入门开发教程
Thank you for your recognition! One thank-you note after another

Brief ideas and simple cases of JVM tuning - how to tune

黑帽实战SEO之永不被发现的劫持
随机推荐
黑帽SEO实战之通用301权重pr劫持
Clickhouse synchronous asynchronous executor
JVM调优简要思想及简单案例-怎么调优
Prometheus PushGateway 碎碎念
Unable to access the CVM self built container outside the TKE cluster pod
Several options of F8 are very useful
Installation of pytorch in pycharm
RPM 包的构建 - SPEC 基础知识
Rasa 3. X learning series -rasa 3.2.0 new release
Record the creation process of a joke widget (I)
How to select a high-performance amd virtual machine? AWS, Google cloud, ucloud, Tencent cloud test big PK
Iguard6.0 - appropriate website protection system
How to bypass CDN to get web pages? How many options are available?
The medical technology giant was blackmailed and Microsoft announced 74 security vulnerabilities | global network security hotspot
Optimization of digital transformation management of procurement platform in construction industry
Yuanqi forest pushes "youkuang", and farmers' mountain springs follow the "roll"?
web渗透测试----5、暴力破解漏洞--(7)MYSQL密码破解
Web penetration test - 5. Brute force cracking vulnerability - (4) telnet password cracking
Summary of rust high concurrency programming
What is the difference between server leasing and hosting?