Thread: macro (#define) question

  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 05:06 PM.
    Hope is the first step on the road to disappointment.

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, 12:52 PM
  2. Would someone solve my problem?
    By Lonners in forum C Programming
    Replies: 9
    Last Post: 01-19-2008, 06: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, 09:44 AM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM