HP aC++/HP C A.06.25 Programmer's Guide
printf("%d \n",firefly );
}
Example 2
You can use the # and ## operators together:
#include <iostream.h>
#define show_me(arg) int var##arg=arg;\
cout << "var" #arg " is " << var##arg << "\n";
int main()
{
show_me(1);
}
Preprocessing this example yields the following code for the main procedure:
int main()
{
int var1=1; cout << "var" "1" " is " << var1 << "\n";
}
After compiling the code with aCC and running the resulting executable file, you get
the following results:
var1 is 1
Spaces around the # and ## are optional.
In both the # and ## operations, the arguments are substituted as is, without any
intermediate expansion. After these operations are completed, the entire replacement
text is rescanned for further macro expansions.
162 Preprocessing Directives