当前位置:网站首页>Pointer initialization
Pointer initialization
2022-07-02 08:25:00 【kq1983】
initialization
Pointer initialization : Address of a variable Memory address Or string constants perhaps NULL
Address of a variable
int i= 10;
int *p2 = &i; // Statement 1 A pointer to the p2, And directly initialize it as a variable i Value
char letter = 'L';
char *myLetter = &letter; // Statement 1 Pointer variables myLetter And directly initialize to letter The address of
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
Memory address
char * name = (char*)malloc(10); // Statement 1 Character pointer name
strcpy(name, "abcde123456");
printf("name=%s \n",name);
- 1.
- 2.
- 3.
- 4.
String constant
char * mystr = "welcome to c!"; // String constant
- 1.
NULL
NULL The address does not exist in memory , yes 0 Address
int *p1 = NULL;// Declare pointer variables p1, And initialize to NULL
- 1.
Wild pointer
char *p;
printf("p=%c \n",*p); // Will report a mistake
- 1.
- 2.
The wrong case
# *p p Must be a valid address , Otherwise, the program will crash
Wild pointer
char *p;
printf("p=%c \n",*p);
- 1.
- 2.
NULL
char *p = NULL;
printf("p=%s \n",*p);
- 1.
- 2.
边栏推荐
- Summary of one question per day: String article (continuously updated)
- Smart agriculture solutions smart agriculture system development
- Sparse matrix storage
- Carsim-实时仿真的动画同步问题
- c语言自定义类型枚举,联合(枚举的巧妙使用,联合体大小的计算)
- [dynamic planning] p4170: coloring (interval DP)
- SQL operation database syntax
- 用数字 5,5,5,1 ,进行四则运算,每个数字当且仅当用一次,要求运算结果值为 24
- How to wrap qstring strings
- Realize bidirectional linked list (with puppet node)
猜你喜欢
Principes fondamentaux de la théorie musicale (brève introduction)
Using transformer for object detection and semantic segmentation
Several methods of image enhancement and matlab code
Carsim problem failed to start Solver: Path Id Obj (X) was set to y; Aucune valeur de correction de xxxxx?
Rotating linked list (illustration)
STM32-新建工程(参考正点原子)
Valin cable: BI application promotes enterprise digital transformation
OpenCV 6.4 中值滤波器的使用
How to wrap qstring strings
On the confrontation samples and their generation methods in deep learning
随机推荐
Animation synchronization of CarSim real-time simulation
Global and Chinese markets of tilting feeders 2022-2028: Research Report on technology, participants, trends, market size and share
Summary of one question per day: stack and queue (continuously updated)
使用Matplotlib绘制图表初步
Find and rfind methods in string
Comparable,Comparator,Clonable 接口使用剖析
Carla-UE4Editor导入RoadRunner地图文件(保姆级教程)
Brief introduction of prompt paradigm
Implementation of bidirectional linked list (simple difference, connection and implementation between bidirectional linked list and unidirectional linked list)
Carla-ue4editor import Roadrunner map file (nanny level tutorial)
Constant pointer and pointer constant
Wang extracurricular words
Sparse matrix storage
Global and Chinese market of medicine cabinet 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of electric cheese grinder 2022-2028: Research Report on technology, participants, trends, market size and share
Smart agriculture solutions smart agriculture system development
Fundamentals of music theory (brief introduction)
Matlab-其它
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
Opencv3 6.3 reduced pixel sampling with filters