|
|
print values of a struct without knowing the slot names
Dear ALL,
I need to understand how I can print out a struct.
Assume ebb1 is an existing struct with values from which I do not know
its slot names.
Here is my (not working ) attempt.
Any idea how to make it running ?
foreach( (slot value) ebb1->?
printf("%s\n" slot))
/* The statement below can not work as slot is not treated as a
variable.
How to make it right ? */
printf("%L\n" ebb1->slot);
)
|
|
0
|
|
|
|
Reply
|
Rolf.Kemper (44)
|
8/12/2008 10:00:35 AM |
|
> Here is my (not working ) attempt.
>
> Any idea how to make it running ?
>
> foreach( (slot value) ebb1->?
> printf("%s\n" slot))
> /* The statement below can not work as slot is not treated as a
> variable.
> How to make it right ? */
> printf("%L\n" ebb1->slot);
> )
>
What you're looking for is get(ebb1 slot).
Note that the -> operator is equivalent to getq(), which means the second argument (slot) is not
evaluated ; since the slot name - which you want to access - is in the value of the slot variable
(symbol), you need to evaluate it by using get().
St�phane
|
|
0
|
|
|
|
Reply
|
stephane.badel1 (446)
|
8/12/2008 10:35:58 AM
|
|
On Aug 12, 4:35 am, "S. Badel" <stephane.ba...@REMOVETHISepfl.ch>
wrote:
> > Here is my (not working ) attempt.
>
> > Any idea how to make it running ?
>
> > foreach( (slot value) ebb1->?
> > printf("%s\n" slot))
> > /* The statement below can not work as slot is not treated as a
> > variable.
> > How to make it right ? */
> > printf("%L\n" ebb1->slot);
> > )
>
> What you're looking for is get(ebb1 slot).
>
> Note that the -> operator is equivalent to getq(), which means the second=
argument (slot) is not
> evaluated ; since the slot name - which you want to access - is in the va=
lue of the slot variable
> (symbol), you need to evaluate it by using get().
>
> St=E9phane
Also,
ebb1->??
is useful for examining an unkown structure.
|
|
0
|
|
|
|
Reply
|
joel_cooper (18)
|
8/13/2008 3:25:37 PM
|
|
|
2 Replies
40 Views
(page loaded in 0.059 seconds)
Similiar Articles: gdb (linux) "print" command clears memory corruption - so how do I ...... program when the debugger "print ... in the same manner as the gdb print command does. I still would be interested in knowing if ... Archive-name: cdrom/cd-recordable ... LSA Disk Sector Read - using int 13h ah 42 (extended read) - comp ...struct disk_packet //needed for int13 42h { BYTE ... was obviously defined with room for a larger value. ... I'd presume, without knowing as fact, that the address operator ... Static reflection - a base for runtime reflection? - comp.lang.c++ ...... ClassA', for struct ClassA { int _myField; }; name_literal< first< fields<ClassA> > > >::value ... just one liner to print out ... running HPUX 11i, without ... Unicode Character to Font Mapping - comp.fontsBased on the character value, i want to find out the ... Knowing the language of some text is mostly not needed ... choice--this is not saying that "serif" is the name of ... how to transpose large matrix? - comp.unix.shell... the transpose of this matrix, and do so without ... newlines for(i=1;i<=NF;i++) print "" > names[i ... Compare Row values Vs Column Name - comp.soft-sys.sas... comp ... Odd BACKUP error: unsupported file structure ! - comp.os.vms ...Knowing what causes this error message might ... kept the source to just the device name so it ... RMS indexed structure. ... inplace edit without backup file ... file - comp ... Bad use of stringstream temporary? - comp.lang.c++... object in a custom class type: struct ... for void*, and so > should again print out the pointer value rather ... Not knowing more about && might lead to bad ... improve strlen - comp.lang.asm.x86... approach in their K8 architechture, but knowing the x86 ... think one or two variables could be dropped out without ... why aren't all these people using a better data structure ... Weird Error Message - comp.cad.solidworksPerhaps the total path and file name is too ... import the part files and assemble them without ... Odd BACKUP error: unsupported file structure ! - comp.os.vms ... Knowing what ... size of a derived type containing pointers... - comp.lang.fortran ...... TYPE TYPE(T) A(2) PRINT ... possibly under a different > name. I would be very interested in knowing if ... to be able to memcpy() a scalar struct ... Java Tutorial: Java Objects... and used without knowing at compile time what the class name is ... one that takes values for first name ... root of the structure, and the fully-qualified name of ... AWK - Wikipedia, the free encyclopediaAs handy syntactic sugar, /regexp/ without using ... record separator (ORS) whose default value is a ... print "expression" > "file name" or through a pipe: 7/18/2012 9:53:06 AM
|
|
|
|
|
|
|
|
|