views:

80

answers:

3

Is there a way to get all the elements of a structure, so I can use them and perhaps iterate over them and print them ?

+1  A: 

There isn't any reflexion in C: you'll have to "fake" one.

jldupont
A: 

C does not provide a standard way to do this. However, you may be able to hack something using the C preprocessor and the offsetof GNU C extension.

Pierre Bourdon
+2  A: 

This is possible with X-macros. See this answer where I demonstrate exactly this.

philippe
This is in fact a duplicate of that questions, so we should close...
dmckee
You're right, I voted to close this one, too.
philippe