c语言中,结构体的赋值

c语言里,不能直接在定义结构体时,给其中元素赋值。

#include<stdio.h>
#include<malloc.h>
typedef struct tree
{
    int data;
    struct tree *left;
    struct tree *next=NULL;
}zhizhen;
int main()
{
    struct tree *a;
    a=(zhizhen*)malloc(sizeof(zhizhen));
    if(a->next==NULL)
    printf("asdfasdfa\n");
    else
    printf("no\n");
    return 0;
}

结果为:no

posted @ 2017-11-04 16:10  balance_uit  阅读(1334)  评论(0)    收藏  举报