当前位置:网站首页>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;
}边栏推荐
- Contrôle de l'exécution du module d'essai par panneau dans Canoe (primaire)
- [untitled]
- CANoe仿真功能之自动化序列(Automation Sequences )
- 《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
- June brush question 01 - array
- Une grande vague d'attaques à la source ouverte
- Automation sequences of canoe simulation functions
- 五月刷题01——数组
- 嵌入式开发中的防御性C语言编程
- Why data Tiering
猜你喜欢

DCDC power ripple test

Compilation of libwebsocket

五月集训总结——来自阿光

Hugo blog graphical writing tool -- QT practice

Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work

Nc29 search in two-dimensional array

O & M, let go of monitoring - let go of yourself

Counter attack of noodles: redis asked 52 questions in a series, with detailed pictures and pictures. Now the interview is stable
![[deep learning] semantic segmentation - source code summary](/img/2c/50eaef4a11fe2ee9c53a5cebdd69ce.png)
[deep learning] semantic segmentation - source code summary

听哥一句劝,按这套嵌入式的课程内容和课程体系去学习
随机推荐
068. Find the insertion position -- binary search
[deep learning] semantic segmentation: paper reading: (2021-12) mask2former
嵌入式开发中的防御性C语言编程
What you have to know about network IO model
Design and implementation of online snack sales system based on b/s (attached: source code paper SQL file)
为什么大学单片机课上51+汇编,为什么不直接来STM32
[NLP] bert4vec: a sentence vector generation tool based on pre training
嵌入式開發中的防禦性C語言編程
机械工程师和电气工程师方向哪个前景比较好?
Combined search /dfs solution - leetcode daily question - number of 1020 enclaves
Yarn organizational structure
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
Some thoughts on the study of 51 single chip microcomputer
vscode 常用的指令
C#/. Net phase VI 01C Foundation_ 01: running environment, process of creating new C program, strict case sensitivity, meaning of class library
May brush question 27 - figure
Hard core! One configuration center for 8 classes!
Programmation défensive en langage C dans le développement intégré
CAPL 脚本对.ini 配置文件的高阶操作