Multiline Macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saswatdash83
    New Member
    • Apr 2008
    • 4

    Multiline Macro

    Hi All,

    I want to implement a macro which will toggle a bit in a byte.The user will give input from keyboard.

    toggle(number,b it to be toggled)
    Number,bit to be toggled will be input from keyboard.

    eg:-suppose user want to toggle 2nd bit of a 8 bit number 10010011.

    Then have to implement the macro toggle(10010011 , 2)
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Wrtite the code to do this and then convert it to a macro.

    I assume you are coding C because C++ uses a bitset object for this.

    Comment

    • saswatdash83
      New Member
      • Apr 2008
      • 4

      #3
      Originally posted by weaknessforcats
      Wrtite the code to do this and then convert it to a macro.

      I assume you are coding C because C++ uses a bitset object for this.

      yes I'm coding C.I don't know the syntax for multiline macro.

      Comment

      • saswatdash83
        New Member
        • Apr 2008
        • 4

        #4
        Could anybody write the code systematically.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          Here you go. Use the \ as the continuation character.

          #define DOIT(x,y) int z = x + y;\
          printf("%d\n", z);

          int main()
          {
          DOIT(3,4);
          }

          Comment

          Working...