How to token paste a number?

104 views Asked by At

I have to create objects dynamically. So for that I have the following:

#define timerID(num) timerID_##num

This results in as timerID_num instead of say timerID_1. Can someone let me know how to do this?

1

There are 1 answers

3
Amol Saindane On

Check following code snippet:

#define f(g,g2) g##g2

void main()
{
   int timerID_1 = 12;
   printf("%d",f(timerID_,1)); 
}

This will concatenate to timerID_1. I printed the value just for debug.