Home » C programming language

Token Pasting Directive Operator (##) in C

Operator ## is known as Token Pasting Directive Operator in C, which is used to concatenate Macro's arguments.

Defining Macro with ## Operator

#define macro_function(argument1, argument2)    argument1##argument2

Consider the following example

#include <stdio.h>

#define CONCAT(x,y) x##y

int main()
	printf("value1: %d\n",CONCAT(10,20));
	printf("value2: %d\n",CONCAT(10,20)+100);	
	return 0;


value1: 1020
value2: 1120

Here, statement CONCAT(10,20) will return 1020 as integer and statement CONCAT(10,20)+100 will concatenate 10, 20 and then add 100 to the 1020, so this statement will return 1120 as integer.

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.