首页 > 编程语言 > 详细

c语言中,结构体的赋值

时间:2017-11-04 17:08:14      阅读:248      评论:0      收藏:0      [点我收藏+]

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

c语言中,结构体的赋值

原文:http://www.cnblogs.com/Club-IT/p/7783638.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!