函数中结构指针的地址为0x1 当我在输出中C++的项目P1地址为0x1 struct f_52 { char s[10]; int *pi; }; struct f_51 { int i; char *pc; f_5

函数中结构指针的地址为0x1 当我在输出中C++的项目P1地址为0x1 struct f_52 { char s[10]; int *pi; }; struct f_51 { int i; char *pc; f_5,c++,pointers,C++,Pointers,函数中结构指针的地址为0x1 当我在输出中C++的项目P1地址为0x1 struct f_52 { char s[10]; int *pi; }; struct f_51 { int i; char *pc; f_52 *ps; }; void function_1() { struct f_51 *p1; struct f_52 *p3; cout<<"Address p1:\t"<<p

函数中结构指针的地址为0x1

当我在输出中C++的项目P1地址为0x1

struct f_52
{
    char s[10];
    int *pi;
};
struct f_51
{
    int i;
    char *pc;
    f_52 *ps;
};
void function_1()
{
    struct f_51 *p1;
    struct f_52 *p3;
    cout<<"Address p1:\t"<<p1<<endl;
    cout<<"Address p3:\t"<<p3<<endl;
    p1 = new f_51;
    cout<<"================================\n";
    cout<<"Address p1:\t"<<p1<<endl;
    cout<<"        p1.i:\t"<<p1->i<<endl
        <<"        p1.pc:\t"<<*(p1->pc)<<endl
        <<"Address p1.ps:\t"<<p1->ps<<endl;
    //cout<<"        p3.pi:\t"<<*(p3->pi)<<endl;
}
int main()
{
    function_1();
}
struct f_52
{
chars[10];
int*pi;
};
结构f_51
{
int i;
char*pc;
f_52*ps;
};
空洞函数_1()
{
结构f_51*p1;
结构f_52*p3;

CUT< P>没有任何指针被初始化,因此它们有随机值。对任何等待不同月阶段的代码进行更改,值将改变。不要使用未分配指针。在C++未初始化的局部变量中,

未初始化。它们的值是不确定的,并试图以任何方式使用它们,而不在其中。初始化导致。您发布了两个
地址p1:
中的哪一个输出行?第一个输出一个初始化指针
p1
cout