当前位置:网站首页>The structure pointer must be initialized, and the pointer must also be initialized
The structure pointer must be initialized, and the pointer must also be initialized
2022-07-29 04:02:00 【Xiaowa 123】
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
typedef struct
{
int a;
int b[5];
}Node;
int main(void)
{
Node* node=(Node*)malloc(sizeof(Node));// Structure pointer initialization , The procedure is correct
node->a=5;
printf("a=%d",node->a);
return 0;
}#include"stdio.h"
#include"stdlib.h"
#include"string.h"
typedef struct
{
int a;
int b[5];
}Node;
int main(void)
{
Node* node;// Structure pointer is not initialized , Program error .
node->a=5;
printf("a=%d",node->a);
return 0;
}As long as the pointer is used , It's about initialization , Whether it is a structure pointer or a structure member variable pointer , Or pointers to other variable types , As long as the pointer is involved , It's about initialization . Because the compiler cannot automatically make the pointer point to a certain memory area when allocating memory . therefore , As long as the pointer is involved , You need to initialize it .
边栏推荐
- 【C语言入门】ZZULIOJ 1031-1035
- 通过PWM呼吸灯和PWM控制直流电机来详细介绍TIM的输出比较功能
- Batch production and upload sales NFT opensea eth polygon
- MySQL Part 3
- Problems encountered in vscode connection SSH
- [introduction to C language] zzulioj 1031-1035
- 企业网的三层架构
- Typescript from getting started to mastering (XXII) namespace namespace (I)
- Solve the delay in opening the console of Google browser
- VScode连接ssh遇到的问题
猜你喜欢

Is the array name a pointer

大厂们终于无法忍受“加一秒”了,微软谷歌Meta等公司提议废除闰秒

Summary on the thought of double pointer

力扣面试题17.04 消失的数字||260.只出现一次的数字(内含位运算知识点)

华为天才少年稚晖君做了一把模块化机械键盘,引起极客圈地震,网友:这才是真正的客制化...

数据挖掘——关联分析基础介绍(上)

Note: restframe work records many to one tables, how to serialize in that table (reverse query)

BGP的基础配置---建立对等体、路由宣告

OA项目之会议通知(查询&是否参会&反馈详情)

Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
随机推荐
Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
大厂们终于无法忍受“加一秒”了,微软谷歌Meta等公司提议废除闰秒
Process tracking of ribbon principle
Batch production and upload sales NFT opensea eth polygon
Solve the problem of garbled code when opening the project code in idea
Several cases of word wrapping in div
Microcomputer principle and interface technology
路由 知识
小马智行进军前装量产,从自研域控制器入手?
数据挖掘——关联分析例题代码实现(下)
Problems encountered in vscode connection SSH
SQL server how to judge when the parameter received by the stored procedure is of type int?
Ribbon principle analysis namedcontextfactory
Typescript from entry to mastery (XXI) generic types in classes
flink-sql 如何设置 sql执行超时时间
JS realizes the function of one click Copy
Common methods of lodash Library
Shopify seller: EDM marketing should be combined with salesmartly to easily get the conversion rate
Typescript from introduction to proficiency (XXIV) using import syntax
[原理] 横向渗透的几种方式