Thread: Printing a special type?

  1. #1
    Registered User
    Join Date
    Apr 2009

    Question Printing a special type?

    Hey guys, I'm trying simply to print the property called "NodeKind" within my syntax tree. It's declared as such:

    typedef enum {VarK,IdK,OpK,ConstK,ComK} NodeKind;
    Every node in my tree has a "kind" pointer. But when I try to use the following print statement, nothing is printed:

    printf("%s", ptree->kind);
    Is there a special way to print out special types like this? Thanks to anyone for any help!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You have to make your own translation, e.g. use an array of strings and index with your enum type.

    There is no way at runtime to tell what the different enum types are called - that information disappears when the compiler generates the code.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation Fault?
    By John_L in forum C Programming
    Replies: 10
    Last Post: 10-02-2007, 08:37 AM
  2. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM