当前位置:网站首页>C language learning log 1.16
C language learning log 1.16
2022-06-13 04:57:00 【Today is also a day without baldness】
Pointer arithmetic :
+n: Add... To a pointer 1 Indicates that you want the pointer to point down n A variable . for example : int a[10]; int *p = a; *(p+1) ---->a[1]
If the pointer is not pointing to the space allocated continuously on one side , Such as arrays , Then this operation is meaningless .
Other operators (+、-、+=、-=) from + You know :“-” Is the pointer pointing forward to the variable .
*p++: Take out p The data referred to comes from , When you're done, drop in p Move to the next position ,* High priority though , But no ++ high , It is often used for continuous space operation of array class , In some CPU On , This can be translated directly into an assembly instruction .
Pointer comparison :
<,<=,==,>,>=,!= Can do... On the pointer , Compare their addresses in memory , The cell addresses in the array must be linearly increasing .
0 Address :
In every program 0 Address , however 0 Address is usually an address that can't be touched , So your pointer should not have 0 value , So you can use 0 Address to show special things :
The returned pointer is invalid
The pointer is not really initialized ( Initialize to 0)
NULL Is a predefined symbol , stay C Language is used to express 0 Address , Because some compilers don't want you to use 0 To express 0 Address .
The type of pointer :
No matter what kind of , All pointers are the same size , Because it's all addresses . But pointers to different types cannot be assigned directly to each other , This is to avoid using the wrong pointer .
Type conversion :void* A pointer indicating that you don't know what to point to , Calculate with char* identical ( But it's not connected ), Pointers can also be converted to types , for example : int *p=&i void*q=(void*)p; It doesn't change p Type of variable referred to , But let the back pass with different eyes p Look at the variables it refers to , from q Just look at it i As int But as void;
What is the pointer used for :
1. Use as a parameter when large data needs to be passed in .2. After passing in the array, operate on the array .3. Function returns more than one result , You need to use functions to modify more than one variable .4. Dynamically requested memory .
边栏推荐
- 2022 oxidation process operation certificate examination question bank and simulation examination
- 无限循环滚动代码阿里巴巴国际站店铺装修代码底图滚动黑色半透明显示效果自定义内容装修代码全屏显示
- Design system based on MVC using javeswingjdbc
- 利用Javeswingjdbc基於mvc設計系統
- Section 3 - functions
- Must know must know -c language keywords
- PowerShell: because running scripts is prohibited on this system, the solution
- [untitled]
- LeetCode第297场周赛(20220612)
- Article 49: understanding the behavior of new handler
猜你喜欢

UNO

C disk lossless move file

Robot pose description and coordinate transformation

Bomb disposal cat

Embedded hardware - read schematic

Analysis on the usage, response and global delivery of provide/inject
![C#获取WebService接口的所有可调用方法[WebMethod]](/img/44/4429b78c5b8341ed9a4a08d75a683e.png)
C#获取WebService接口的所有可调用方法[WebMethod]

QT realizes message sending and file transmission between client and server

2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation

Mind mapping series - Database
随机推荐
Gradient descent, learning rate
Advanced C - Section 3 - character functions and string functions
Must know must know -c language keywords
General communication protocol for industrial Internet
Chapter 13 abstraction: address space
Brick story
RMQ、LCA
Construction problem of D Xiaohong
Embedded hardware - read schematic
Chapter 18 pagination: Introduction
[JS solution] leedcode 200 Number of islands
All blog navigation
Section 3 - functions
The games that you've tasted
PowerShell plus domain add computer module
QT brushes and brushes
Kaggle 时间序列教程
135. distribute candy
The processing flow of thread pool depends on the core parameters
Chapter 14 introduction: memory operation API