macro's

This is a discussion on macro's within the C Programming forums, part of the General Programming Boards category; I'm trying to put a basic menu in a macro so that it can be called quickly and easily. I'm ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    11

    macro's

    I'm trying to put a basic menu in a macro so that it can be called quickly and easily. I'm not sure how to put a multiple line statement in a macro. For example:

    #define MENU (printf("Something here \n");
    printf("Something else here \n"); )

    Any help is appreciated.

    Cheers.

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    21
    I'm not entirely sure, but give this a try. It might just work.
    Code:
    #define MENU (printf("Something here \n"); \
                  printf("Something else here \n"); )
    All I'm doing here is pasting the two lines together with a "\" at the end of each line that is to be continued on the next.

    Let me know if this works, now I'm curious.

    Arker.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Yeah. Thanks Arker. When I saw your post I remembered I had done that awhile ago.

    Cheers.

  4. #4
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Just wondering, why do you need 2 printf()'s? You can do it this way as well:
    Code:
    #define MENU printf("Something here \n" \
                  "Something else here \n");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Order of execution of preprocessor macros
    By DL1 in forum C Programming
    Replies: 2
    Last Post: 04-02-2009, 06:52 PM
  2. Pre-processor macros causing segfaults
    By nempo in forum C++ Programming
    Replies: 6
    Last Post: 02-10-2009, 01:35 AM
  3. Macros inside of macros
    By Chewie8 in forum C Programming
    Replies: 2
    Last Post: 02-24-2008, 02:51 AM
  4. Macros vs Inline Functions
    By vb.bajpai in forum C Programming
    Replies: 4
    Last Post: 08-02-2007, 11:51 AM
  5. template fn replacements for msg macros
    By Ken Fitlike in forum Windows Programming
    Replies: 17
    Last Post: 10-30-2002, 06:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21