The # and ## Preprocessor Operators - C Preprocessor

C examples for Preprocessor:Preprocessor Operators

Introduction

# operator turns the argument it precedes into a quoted string. For example, consider this program:

Demo Code

#include <stdio.h>

#define mkstr(s) # s//from   w  w w. j a v a2 s. c  om

int main(void)
{
   printf(mkstr(I like C));

   return 0;
}

Result

## operator concatenates two tokens. For example:

Demo Code

#include <stdio.h>

#define concat(a, b) a ## b//w ww.j  a v  a  2s.  c o m

int main(void)
{
   int xy = 10;

   printf("%d", concat(x, y));

   return 0;
}

Result


Related Tutorials