struct's struct?

Posted By: tzw

struct's struct? - 04/30/11 10:56

hi,everybody. a question make me confused? is a struct can directly have a member struct.i mean DO NOT use a pointer. someone can tell me about it?
Posted By: HeelX

Re: struct's struct? - 04/30/11 11:19

Yes, why not? It would be cooler, if you would test it out by yourself, but I don't mind doing that for you:

Code:
typedef struct
{
   int a, b;
   float c;
   STRING* d;
} STRUCT_A;

typedef struct
{
   int e, f;
   BMAP* h;
   
   STRUCT_A aaa, bbb;
} STRUCT_B;

void main ()
{
   STRUCT_B test;
   test.aaa.a = 10;
   test.bbb.b = 2;
   test.aaa.a *= test.bbb.b;

   // works
   printf("test.aaa.a = %d", test.aaa.a);
}



Have fun!
Posted By: tzw

Re: struct's struct? - 04/30/11 11:33

thanks you!!
© 2024 lite-C Forums