printing structure elements with MACRO 
Author Message
 printing structure elements with MACRO

Hi,

Is there any generic way to print the name and value of all the elements
in any structure elements using MACRO (like it is possible with variable
by using #variable in a macro).

For example, if a struct is

{
    int a;
    int b;
    int c;

Quote:
} exampleStruct_1;

then

printStructure(exampleStruct_1) should print

a=3
b=4
c=5

Now if I pass another structure say,
{
int x;
int y;
int z;

Quote:
}exampleStruct_2;

printStructure(exampleStruct_2) should print

x=7
y=7
z=8

It is ok to have assumption that all the structure elements are of the
same type (for C).

Regards,
Yusuf
--



Sun, 27 Oct 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. making pointers to structure elements using array elements

2. CPP: macro with variable number of elements

3. sizeof an element of a structure

4. Help with structure element casting required

5. Comparing Structure Elements

6. Setting structure array elements

7. Getting address of element of structure array.

8. updating structure elements from a pointer passed to the function

9. Setting elements in a structure array

10. Passing pointers to elements of a structure.

11. Using NULL for optional structure elements

12. help on sizeof of structure element

 

 
Powered by phpBB® Forum Software