当前位置:网站首页>[C language - zero foundation lesson 11] rotate the pointer of the big turntable
[C language - zero foundation lesson 11] rotate the pointer of the big turntable
2022-07-27 09:15:00 【Super Daxiong】
Preface :
Blogger :Super Daxiong ( A cute new blogger )
C Language column :0 Basic science C Language column
LeetCode special column :LeetCode special column
This issue is about the pointer of rotating the turntable , If there is any mistake, please point out thank you !
Recommend one to my friends Study 、 Brush problem Website ?
Various Interview questions have everything that one expects to find , Brush questions until you feel soft !
All kinds of Internet Learning materials , The real interview questions of major factories start from Start learning from scratch , Help you cope easily Various interview questions , Come and enrich yourself !Click Start registration Study 、 Brush problem
Catalog
What is the pointer ?
In life, we should have played the game of spinning the big wheel , I will take away the object that the pointer points to , This is the pointer . In real life, did you win the prize by playing the game of rotating the turntable ? Another is our house number. We can think of it as a pointer , As long as we tell others our house number, he can follow it to find you , And in us C There are also pointers in languages .
Pointer definition
To make it clear what a pointer is , We must first find out how the data is stored in memory , How to store and read . If a variable is defined in the program , When compiling a program , The system allocates memory units to this variable . The compilation system is based on the variable types defined in the system , Assign a certain length . Each byte of the memory area has a number , This is it. “ Address ”, It is equivalent to the house number in the hotel . The data stored in the memory unit marked by the address is equivalent to the passengers living in the hotel room .
Because the variable unit can be found through the address , so to speak , The address points to the variable unit . For example, the door of a room is hung 201 room , This is the address of the room . Or say ,201“ Point to ” The room . therefore , Visualize the address as “ The pointer ”. Through it, you can find the memory unit with its address .
Pointer is address , The pointer to a variable is the address of the variable .
Definition of pointer
The general form of defining a pointer variable is : Base address * Pointer to the variable
* Indicate symbols for pointers
int *p;Assignment of pointer
1. By taking the address operator :&
int a,*b;
b=&a;2. Through another address
int a,*q,*p;
q=&a;
p=q;3. Definition of null pointer
int *p=NULL;explain
1. NULL Said empty , Its value is 0
2. Null pointer cannot be referenced after definition
Pointer operation
&: Fetch address operator Only address the content
*: Take the content operator You can only get the content from the address
#include<stdio.h>
int main(){
int a=5,b,*p;
p=&a;
b=*p;
printf("%d\n",b);
}
result :5
Reference to pointer
Input two values to exchange their values, and then output
int a,b,*p,*q;
q=&a;
p=&b;
scanf("%d%d",q,p);
printf("%d,%d\n",a,b);//5,5
printf("%d,%d\n",*q,*p);//5,5
*q=3;
*p=2;
printf("%d,%d\n",a,b);//3,2Address passing between functions
#include<stdio.h>
void fun(int *q,int *p){
*q+=*p;
*p+=*q;
}
int main(){
int a=5,b=2;
fun(&a,&b);
printf("%d,%d\n",a,b);//3,2
}
Recommend one to my friends Study 、 Brush problem Website ?
Various Interview questions have everything that one expects to find , Brush questions until you feel soft !
All kinds of Internet Learning materials , The real interview questions of major factories start from Start learning from scratch , Help you cope easily Various interview questions , Come and enrich yourself !
边栏推荐
- Principle of flex:1
- Pymongo fuzzy query
- ES6 new - string part
- ES6 new symbol data type
- Solve the problem of Chinese garbled code on the jupyter console
- ES6 new - array part
- Five kinds of 2D attention finishing (non local, criss cross, Se, CBAM, dual attention)
- The difference between computed and watch
- 微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
- CUDA Programming -03: thread level
猜你喜欢

拍卖行做VC,第一次出手就投了个Web3

Unity3d 2021 software installation package download and installation tutorial

As a VC, the auction house invested Web3 for the first time

CUDA Programming -03: thread level

Restful

Five kinds of 3D attention/transformer finishing (a-scn, point attention, CAA, offset attention, point transformer)

8 kinds of visual transformer finishing (Part 2)

Deep understanding of Kalman filter (2): one dimensional Kalman filter

PVT's spatial reduction attention (SRA)

MySQL transaction
随机推荐
易语言编程: 让读屏软件可获取标签控件的文本
Five kinds of 3D attention/transformer finishing (a-scn, point attention, CAA, offset attention, point transformer)
存储和计算引擎
qt中使用sqlite同时打开多个数据库文件
Flex layout (actual Xiaomi official website)
Sharing of four open source face recognition projects
CUDA programming-04: CUDA memory model
Interface test tool -postman usage details
Deep understanding of Kalman filter (1): background knowledge
"Weilai Cup" 2022 Niuke summer multi school training camp 1
linux下安装oracle,本地PL/SQL连接Linux下的oracle导入表并新建用户和密码
Explanation of binary tree
PVT's spatial reduction attention (SRA)
Explicit animation in arkui
MySQL basic knowledge learning (I)
Matlab solves differential algebraic equations (DAE)
ES6 new - array part
Openharmony Mengxin contribution Guide
5g failed to stimulate the development of the industry, which disappointed not only operators, but also mobile phone enterprises
【ACL2020】一种新颖的成分句法树序列化方法