当前位置:网站首页>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;
}边栏推荐
- 五月刷题02——字符串
- June brush question 01 - array
- Several ways of MySQL database optimization (pen interview must ask)
- Why is 51+ assembly in college SCM class? Why not come directly to STM32
- [Yu Yue education] reference materials of power electronics technology of Jiangxi University of science and technology
- 在CANoe中通過Panel面板控制Test Module 運行(初級)
- MapReduce working mechanism
- 手把手教您怎么编写第一个单片机程序
- Canoe cannot automatically identify serial port number? Then encapsulate a DLL so that it must work
- A wave of open source notebooks is coming
猜你喜欢

Teach you how to write the first MCU program hand in hand

33岁可以学PLC吗

大学想要选择学习自动化专业,可以看什么书去提前了解?

CAP理论

Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions

零基础学习单片机切记这四点要求,少走弯路

tn-c为何不可用2p断路器?

What are the models of data modeling
![[NLP] bert4vec: a sentence vector generation tool based on pre training](/img/fd/8e5e1577b4a6ccc06e29350a1113ed.jpg)
[NLP] bert4vec: a sentence vector generation tool based on pre training

CAPL脚本中关于相对路径/绝对路径操作的几个傻傻分不清的内置函数
随机推荐
Cap theory
Tianmu MVC audit II
Download address of canoe, download and activation of can demo 16, and appendix of all canoe software versions
Random notes
Scoped in webrtc_ refptr
Learning SCM is of great help to society
Configure system environment variables through bat script
[deep learning] semantic segmentation - source code summary
在CANoe中通過Panel面板控制Test Module 運行(初級)
Can I learn PLC at the age of 33
【深度学习】语义分割:论文阅读:(2021-12)Mask2Former
Hero League rotation chart manual rotation
MapReduce instance (x): chainmapreduce
硬件工程师的真实前途我说出来可能你们不信
Delayed note learning
Competition vscode Configuration Guide
The replay block of canoe still needs to be combined with CAPL script to make it clear
CAPL 脚本对.ini 配置文件的高阶操作
一大波开源小抄来袭
MapReduce instance (IV): natural sorting