当前位置:网站首页>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 .
边栏推荐
- Spark dataframe replaces empty characters (or other values) in each column with null
- Is the array name a pointer
- 路西法98-生活记录ing
- 这个报错是什么鬼啊,不影响执行结果,但是在执行sql时一直报错。。。连接maxComputer是使用
- Const read only variable constant
- Opensql quick learning
- A little understanding of pointer, secondary pointer, wild pointer, pointer as function return value
- Array as function parameter -- pointer constant / constant pointer
- 3. Solve pychart's error unresolved reference 'selenium' unresolved reference 'webdriver‘
- CUB_200鸟类数据集关键点可视化
猜你喜欢
Batch production and upload sales NFT opensea eth polygon
tron OUT_ OF_ ENERGY
SQL window function
Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
Connection broken by 'readtimc rt-443): read timed out (read timeout=l5)“)‘: /pac
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
UCOS任务切换过程
面试必备!TCP协议经典十五连问!
Three tier architecture of enterprise network
EMD empirical mode decomposition
随机推荐
【BGP】小型实验
Mmdetection preliminary use
Design of environment detection system based on STM32 and Alibaba cloud
Form verification of landline
Cloudera manager platform fault repair record
CUB_200鸟类数据集关键点可视化
Interview essential! TCP classic 15 consecutive questions!
大佬们flink的JDBC SQL Connector现在不支持所有的数据库吗,例如vertica?
tron OUT_ OF_ ENERGY
Several cases of word wrapping in div
Shopify seller: EDM marketing should be combined with salesmartly to easily get the conversion rate
3. Solve pychart's error unresolved reference 'selenium' unresolved reference 'webdriver‘
Typescript from getting started to mastering (XX) function generics
Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
Tristate gate
MySQL Part 3
SQL server how to judge when the parameter received by the stored procedure is of type int?
C language to achieve three chess game (detailed explanation)
一文学透MySQL表的创建和约束
当我从数据库获取到了winfrom特定的控件ID之后我需要通过这个ID找到对应的控件,并对控件的TEXT文本进行赋值这该怎么做