Thread: Help with Understanding "#define"

  1. #1
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    Help with Understanding "#define"

    In my book, it says that the syntax for #define is
    Code:
    #define macro_name macro_body
    However, I've seen lots of code like this:
    Code:
    #define macro_name
    What does exp. 2 mean?

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1

    macro

    the working of both r similar.

    1. #define MACR0 10

    what this does is it replaces the word MACRO with 10 everywhere in the programme.
    This is used from the clarity of the programme.

    2. # define MACRO

    here u r just defining a macro
    it acts like an if.

    ex.

    #ifdef MACRO
    printf(....)
    #else
    printf(....)

  3. #3
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    Oh!

    That makes sense. I can see lots of ways to use that. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Understanding Headers
    By AeonMoth in forum C++ Programming
    Replies: 2
    Last Post: 06-27-2007, 05:53 AM
  3. trouble understanding the source file structure
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 05-26-2006, 06:46 PM
  4. understanding recursive functions
    By houler in forum C Programming
    Replies: 7
    Last Post: 12-09-2004, 12:56 PM
  5. Replies: 5
    Last Post: 08-31-2004, 06:41 PM