Link to home
Start Free TrialLog in
Avatar of rs_1915
rs_1915

asked on

use #define to name variable

I am trying to name the variable using define
example #define ADDLETTER(a) will add letters 'td' to a, and declare this variable with that name.
So, If i declare int ADDLETTER( a); compiler should compile it as int tda;
second example
int ADDLETTER( bc );
the compiler will compile as
int tdbc;
Is this even possible to do?
ASKER CERTIFIED SOLUTION
Avatar of thienpnguyen
thienpnguyen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkr
That's pretty easy:

#define ADDLETTER(a) td##a

Never mind what those guys say.  I suggest using the token-pasting operator, ##

-- Dan
:o)