当前位置:网站首页>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.
边栏推荐
- Find and rfind methods in string
- A brief analysis of graph pooling
- On the confrontation samples and their generation methods in deep learning
- Short video with goods source code, double-click to zoom in when watching the video
- 力扣方法总结:查找类
- install.img制作方式
- Global and Chinese markets for magnetic resonance imaging (MRI) transmission 2022-2028: Research Report on technology, participants, trends, market size and share
- 用数字 5,5,5,1 ,进行四则运算,每个数字当且仅当用一次,要求运算结果值为 24
- 乐理基础(简述)
- Development of digital collection trading website development of metauniverse digital collection
猜你喜欢

St-link connection error invalid ROM table of STM32 difficult and miscellaneous diseases

Linked list classic interview questions (reverse the linked list, middle node, penultimate node, merge and split the linked list, and delete duplicate nodes)

Fundamentals of music theory (brief introduction)

文件上传-upload-labs

Intelligent manufacturing solutions digital twin smart factory

Web安全--核心防御机制

SQLyog远程连接centos7系统下的MySQL数据库

When a custom exception encounters reflection

How to build the alliance chain? How much is the development of the alliance chain

Generate database documents with one click, which can be called swagger in the database industry
随机推荐
OpenCV3 6.3 用滤波器进行缩减像素采样
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
Find and rfind methods in string
双向链表的实现(双向链表与单向链表的简单区别联系和实现)
Erase method in string
使用wireshark抓取Tcp三次握手
c语言自定义类型枚举,联合(枚举的巧妙使用,联合体大小的计算)
2022 Heilongjiang's latest eight member (Safety Officer) simulated test question bank and answers
Simply test the two different data transmission methods of content length and chunked
MySQL优化
SQL operation database syntax
OpenCV3 6.2 低通滤波器的使用
乐理基础(简述)
Realize bidirectional linked list (with puppet node)
程序猿学英语-指令式编程
IP协议与IP地址
类和对象(类和类的实例化,this,static关键字,封装)
Linked list classic interview questions (reverse the linked list, middle node, penultimate node, merge and split the linked list, and delete duplicate nodes)
Intelligent manufacturing solutions digital twin smart factory
Analysis of the use of comparable, comparator and clonable interfaces