Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I have a structure and I don't know what it is made of. Could somebody tell me how to output/dump a structure to the screen in a command ...
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Posts
    24

    outputting a structure in C

    Hi all,

    I have a structure and I don't know what it is made of. Could somebody tell me how to output/dump a structure to the screen in a command prompt environment using C.

    Joe

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Question

    I'm unable to understand your problem ..
    This is what i understood ,"You have some raw data and you can't able read it because don't know it's structure format" --is this your problem?
    please explain bit..may be someone will help.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Posts
    24
    I have a complex structure that doesn't seem to be able to be output using standard printf methods. Just wondered if there was another way to dump it to
    screen

  4. #4
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    Unlike Java, Python, or Ruby, there's no "to string" function that goes along with each structure in C. If you want to output a structure, you pretty much have to know what it's made of. There are two solutions I can think of:

    * Compile your problem with debugging info (-g), run it through the debugger, and print the structure from there. gdb knows how to print a structure.

    * Find the declaration of the structure (if you can use it, it must be in a file you included) and go from that.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...