当前位置:网站首页>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语言(3)
- Configmap配置与Secret加密
- 数据挖掘——关联分析例题代码实现(下)
- A little understanding of pointer, secondary pointer, wild pointer, pointer as function return value
- 通过PWM呼吸灯和PWM控制直流电机来详细介绍TIM的输出比较功能
- Ribbon principle analysis namedcontextfactory
- 关于ALV格式控制部分的写法
- There is a special cryptology language called asn.1
- 谁能详细说下mysqlRC下的半一致读和怎么样减少死锁概率?
- 路由 知识
猜你喜欢

Beijing post network research 2015 problem2

Configmap configuration and secret encryption

Problems encountered in vscode connection SSH

SQL窗口函数

小马智行进军前装量产,从自研域控制器入手?

UCOS task switching process

1985-2020(8个版次)全球地表覆盖下载与介绍

C language to achieve three chess game (detailed explanation)

Solve the delay in opening the console of Google browser

3. Solve pychart's error unresolved reference 'selenium' unresolved reference 'webdriver‘
随机推荐
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
安装ros的laser_scan_matche库所遇到的问题(一)
I. creation and constraint of MySQL table
第一个ALV程序2
Ssl== certificate related concepts
3.解决Pycharm报错Unresolved reference ‘selenium‘ Unresolved reference ‘webdriver‘
SQL server how to judge when the parameter received by the stored procedure is of type int?
Lua语言(stm32+2G/4G模块)和C语言(stm32+esp8266)从字符串中提取相关数据的方法-整理
[redis series] string data structure
[BGP] small scale experiment
Const char* and char*, string constants
Data mining -- Introduction to the basis of association analysis (Part 1)
Const read only variable constant
Solve the delay in opening the console of Google browser
After I get the winfrom specific control ID from the database, I need to find the corresponding control through this ID and assign a value to the text text of the control. What should I do
The function parameters of the new features of ES6 are assigned initial values and rest parameters
Note: restframe work records many to one tables, how to serialize in that table (reverse query)
数据挖掘——关联分析基础介绍(上)
[principle] several ways of horizontal penetration
First ALV program 2