当前位置:网站首页>Pointer learning
Pointer learning
2022-07-06 09:54:00 【@sen】
One 、 Defining pointer variables
(1) Type name :* Pointer variable name
char *pa; // Define a pointer variable that points to a character type
int *pb; // Define a pointer variable that points to an integer
(2) Take address operator and value operator
If you need to get the address of a variable , You can use the address operator (&):
char *pa=&a;
int *pb=&b;
If you need to access the data pointed to by the pointer variable , You can use the value operator (*):
printf(“%c,%d\n”,*pa,*pb);
#include<stdio.h>
int main()
{
char a = 'F';
int f = 123;
char *pa = &a;
int *pb = &f;
printf("a=%c\n", *pa); // Initial pointer variable
printf("f=%d\n", *pb);
*pa = 'C';
*pb += 1;
printf("now,a=%c\n", *pa); // Change the pointer variable
printf("now,f=%d\n", *pb);
printf("sizeof pa=%d\n", sizeof(pa)); // Print pointer length
printf("sizeof pb=%d\n", sizeof(pb));
printf("the adds a or b is:%p\n",pa); // Access pointer address
printf("the adds a or b is:%p\n", pb);
return 0;
}
** You need to avoid uninitialized pointers
#include <stdio.h>
int main()
{
int *a; // Uninitialized pointer
*a = 123;
return 0;
}边栏推荐
- [NLP] bert4vec: a sentence vector generation tool based on pre training
- 嵌入式开发中的防御性C语言编程
- One article read, DDD landing database design practice
- [deep learning] semantic segmentation: thesis reading (neurips 2021) maskformer: per pixel classification is not all you need
- Listen to my advice and learn according to this embedded curriculum content and curriculum system
- Hugo blog graphical writing tool -- QT practice
- Compress decompress
- CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
- Mapreduce实例(四):自然排序
- Compilation of libwebsocket
猜你喜欢

Interview shock 62: what are the precautions for group by?

Contrôle de l'exécution du module d'essai par panneau dans Canoe (primaire)

tn-c为何不可用2p断路器?
[Yu Yue education] Wuhan University of science and technology securities investment reference

【深度学习】语义分割:论文阅读:(CVPR 2022) MPViT(CNN+Transformer):用于密集预测的多路径视觉Transformer
![[flask] crud addition and query operation of data](/img/fc/7a12ede31befed5f42b32b94ae5ecf.jpg)
[flask] crud addition and query operation of data
![[deep learning] semantic segmentation: paper reading: (2021-12) mask2former](/img/dd/fe2bfa3563cf478afe431ac87a8cb7.png)
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former

Elk project monitoring platform deployment + deployment of detailed use (II)

A wave of open source notebooks is coming

在CANoe中通过Panel面板控制Test Module 运行(高级)
随机推荐
max-flow min-cut
Tianmu MVC audit II
[CV] target detection: derivation of common terms and map evaluation indicators
C杂讲 浅拷贝 与 深拷贝
[NLP] bert4vec: a sentence vector generation tool based on pre training
May brush question 02 - string
CANoe CAPL文件操作目录合集
Une grande vague d'attaques à la source ouverte
Nc17 longest palindrome substring
MapReduce instance (V): secondary sorting
Defensive C language programming in embedded development
Competition vscode Configuration Guide
大学C语言入门到底怎么学才可以走捷径
Canoe CAPL file operation directory collection
CANoe不能自动识别串口号?那就封装个DLL让它必须行
Mapreduce实例(九):Reduce端join
vscode 常用的指令
June brush question 02 - string
Delayed note learning
Contrôle de l'exécution du module d'essai par panneau dans Canoe (primaire)