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?
LVL 1
rs_1915Asked:
Who is Participating?
 
thienpnguyenConnect With a Mentor Commented:
Yes, you can .

#define ADDLETTER( a ) td##a

int main()
{
    int ADDLETTER( bc );

   tdbc = 5;
   return 0;
}
0
 
jkrCommented:
That's pretty easy:

#define ADDLETTER(a) td##a

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

-- Dan
0
 
jkrCommented:
:o)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.