问题遇到的现象和发生背景
在做数据结构时遇到的问题
问题相关代码,请勿粘贴截图
代码:
#include <stdio.h>
typedef struct {
int *p;
}Arr;
int main(){
Arr *B;
int *q;
int b;
B->p = &b;
scanf("%d",&(*(B->p)));
printf("%d",*(B->p));
}
运行结果及报错内容
结果:
C:\Users\86159\CLionProjects\untitled4\cmake-build-debug\untitled4.exe
Process finished with exit code -1073741819 (0xC0000005)
我想要达到的结果
对结构体指针中的指针指向的变量进行赋值和输出