来自下面结构的指针“ p”中包含的值打印错误,我找不到正确打印它的方法。正确的代码是什么?代码:
#include <stdio.h>
struct my_struct{ //structure definition
int a,*p;
};
int main(){
my_struct var;
var.a = 5; //variable definition
var.p = &(var.a); //pointer gets address from variable
printf("%d\n",var.p); // the number 2686744 is printed instead of the number '5'
return 0;
}
Run Code Online (Sandbox Code Playgroud) c ×1