Thread: Preprocessor output issue

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    24

    Post Preprocessor output issue

    Here is the snippet of code. I get missing # in my output. I replaced # with the other special character i.e. "@" & "!", but then I get error.

    Code:
    #define str(x)           #x 
    #define Xstr(x)          str(x) 
    #define oper             multiply 
    main() 
    { 
    char *opername = Xstr (oper)  ; 
    printf  (  "%s",  opername )  ; 
    }
    It should print "#multiply" in output screen instead of multiply.
    Any explanation why multiply rather than #multiply?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    # is the pre-processor stringify operator
    https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Having an output issue working with input file, golf game.
    By douglas481 in forum C Programming
    Replies: 10
    Last Post: 03-29-2012, 05:43 PM
  2. bandwidth issue / network issue with wireless device communication
    By vlrk in forum Networking/Device Communication
    Replies: 0
    Last Post: 07-05-2010, 11:52 PM
  3. Replies: 6
    Last Post: 06-24-2010, 11:12 PM
  4. "sizeof" character strings - output issue
    By bunko in forum C Programming
    Replies: 3
    Last Post: 12-03-2008, 06:10 PM
  5. preprocessor output
    By rohit_second in forum C Programming
    Replies: 6
    Last Post: 09-04-2008, 06:07 AM

Tags for this Thread