How to use anonymous struct in C

1 Answer

0 votes
#include <stdio.h>

struct Test
{
    struct
    {
        char ch;
        int n;
    };
};
 
int main()
{
    struct Test t;
    
    t.ch = 'z';
    t.n = 998;
 
    printf("t.ch = %c  t.n = %d\n", t.ch, t.n);
 
    return 0;
}


/*
run:

t.ch = z  t.n = 998

*/

 



answered Mar 17, 2018 by avibootz

Related questions

1 answer 81 views
81 views asked Nov 22, 2024 by avibootz
1 answer 160 views
160 views asked Dec 27, 2020 by avibootz
1 answer 189 views
1 answer 136 views
136 views asked Mar 17, 2018 by avibootz
1 answer 219 views
1 answer 180 views
180 views asked Mar 17, 2018 by avibootz
1 answer 148 views
148 views asked Mar 17, 2018 by avibootz
...