当前位置:网站首页>[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 !
边栏推荐
- [daily algorithm day 96] Tencent interview question: merge two ordered arrays
- Deep understanding of Kalman filter (3): multidimensional Kalman filter
- pollFirst(),pollLast(),peekFirst(),peekLast()
- PyTorch自定义CUDA算子教程与运行时间分析
- Aruba learning notes 10 security authentication portal authentication (web page configuration)
- ES6 new symbol data type
- CUDA Programming -03: thread level
- What if the parameters in QT are structs or custom classes when sending signals?
- Wechat applet 5 - foundation strengthening (not finished)
- Matlab uses m file to produce fuzzy controller
猜你喜欢

npm install报错 强制安装

The execution sequence of async/await, macro tasks and micro tasks

async/await的执行顺序以及宏任务和微任务

5G没能拉动行业发展,不仅运营商失望了,手机企业也失望了

NPM install error forced installation

Rewrite the tensorrt version deployment code of yolox

Restful

ES6 new - Operator extension

ES6 new - object part

MySQL transaction
随机推荐
npm install报错 强制安装
Antdesign a-modal user-defined instruction realizes dragging and zooming in and out
HUAWEI 机试题:字符串变换最小字符串 js
Huawei machine test question: String transformation minimum string JS
The lifecycle of arkui development framework components
Huawei machine test question: Martian computing JS
Apple cut its price by 600 yuan, which was almost a devastating blow to the collapse of its domestic flagship mobile phone
二叉树讲解
Openharmony Mengxin contribution Guide
Pytorch custom CUDA operator tutorial and runtime analysis
Primary function t1744963 character writing
微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
07_ Service registration and discovery summary
Solve the problem of Chinese garbled code on the jupyter console
Is the operation of assigning values to int variables atomic?
SQL exercise set
全排列递归思路整理
Nutrecipes developed based on arkui ETS
基于restful页面数据交互
罗克韦尔AB PLC 通过RSLinx Classic与PLC建立通信的具体方法步骤