Holla Tech - Learn

Preprocessor Operators
 

The C preprocessor provides the following operators.

The # Operator
The # macro operator is called the stringification or stringizing operator and tells the preprocessor to convert a parameter to a string constant.
White space on either side of the argument are ignored and escape sequences are recognized.

For example: 

#define TO_STR(x) #x

printf(“%s\n”, TO_STR( 123\\12 )); 

 


The ## Operator
 

The ## operator is also called the token pasting operator because it appends, or “pastes”, tokens together.

For example:

#define VAR(name, num) name##num

int x1 = 125;
int x2 = 250;
int x3 = 500; 

printf(“%d\n”, VAR(x, 3)); 

 


BACK NEXT

CLICK ON THE BUTTON BELOW TO GO TO THE C MAIN COURSE PAGE. 

C MAIN COURSE PAGE

 


© License: All Rights Reserved 


CONTACT HOLLA TECH – LEARN SUPPORT