# Connector and # Connector
# The Concatenation symbol is composed of two pound signs. Its function is to connect two substrings (tokens) in the macro definition with parameters to form a new substring. But it cannot be the first or last substring. The so-called token refers to the minimum syntax unit that the compiler can recognize. The specific definition has a detailed explanation in the compilation principle, but it does not matter if you do not know. At the same time, it is worth noting that the # operator replaces the passed parameters as strings. Let's take a look at how they work. This is an example on msdn.
Suppose the program has defined such a macro with parameters:
# Define Paster (n) printf ("token" # N "= % d", Token # N)
At the same time, an integer variable is defined:
Int token9 = 9;
Call this macro in the following way in the main program:
Paster (9 );
During compilation, the above sentence is extended:
Printf ("token" "9" "= % d", token9 );
Note that in this example, the "9" in Paster (9); is regarded as a string and connected with the "token", thus becoming the token9. # N is also replaced by "9.
As you can imagine, the result of running the program above is to print token9 = 9 on the screen.