(C99)复合字面量

#include <stdio.h>

struct argvs
{
    char a[64];
    int b;
};

int pfunc(struct argvs *a)
{
    printf("argvs.a=%s argvs.b=%d\n", a->a, a->b);
}

int func(struct argvs a)
{
    printf("argvs.a=%s argvs.b=%d\n", a.a, a.b);
}

int main(int argc, char *argv[])
{
    struct argvs a =
    {
        .a = "liming",
        .b = 23
    };

    int *pa = (int []){1,2};

    printf("pa[0]=%d\n", pa[0]);

    pfunc(&a);

    func((struct argvs) {"liming", 24});

    //pfunc((struct argvs) {"liming", 24}); //非法

    return 0;
}

posted @ 2019-09-05 20:45  wdliming  阅读(135)  评论(0编辑  收藏  举报