macro (#define) question

This is a discussion on macro (#define) question within the C++ Programming forums, part of the General Programming Boards category; your macros are using them as though they're stings, anything that is not preprocessed that's in the macro well completely ...

  1. #31
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    your macros are using them as though they're stings, anything that is not preprocessed that's in the macro well completely mess it up
    You have no idea what you're talking about.

    Code:
    #include <stdio.h>
    
    #define NUMBERPARTY 5
    #define NUMBERENEMY 9
    #define GROUPCHAR(x) (x)?partychar:enemychar 
    #define GROUPCHAR2(x) (x)?enemychar:partychar 
    #define NUMGROUP(x) (x)?NUMPARTY:NUMENEMY 
    #define CODE(x) (x)?code:code2 
    
    int main ( void )
    {
        int partychar=0, enemychar=0, code=0, code2=0;
        int b=1,c=0;
    
        for( c = 0; c < NUMGROUP(b); c++ )
        {
            if( c > 3 ) b=0;
            code++; //random crap
            code2--; //random crap
            partychar *= code; //random crap
            enemychar += code2; //random crap
            cout << " c=" << c << " gc=" GROUPCHAR(b)
                    << " gc2=" << GROUPCHAR2(b),
                    << " codex=" CODE(b) << endl;
        }
       
        return 0;
    }
    Again, what the hell are you talking about? I never said anything about strings. These macros don't care WHAT you pass them. That's the whole point of using a macro. Or atleast one point...

    Quzah.
    Last edited by quzah; 12-20-2001 at 04:06 PM.
    Hope is the first step on the road to disappointment.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why?!?
    By p3rry in forum C Programming
    Replies: 3
    Last Post: 01-08-2009, 11:52 AM
  2. Would someone solve my problem?
    By Lonners in forum C Programming
    Replies: 9
    Last Post: 01-19-2008, 05:58 PM
  3. Bor to DevC++ prog convert prob
    By kryptkat in forum Windows Programming
    Replies: 16
    Last Post: 09-18-2007, 05:11 AM
  4. float toolbar!
    By c-- in forum Windows Programming
    Replies: 5
    Last Post: 02-04-2003, 08:44 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM

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