What is use of # and ## operator in c program ?

There are two operator in preprocessor.
1. # this operator is called stringizing operator which convert any argument in the macro function in the string. So we can say pound sign # is string maker.
#define string(s) #s
void main()
char str[15]=string(World is our ) ;

Output: World is our
Explanation : Its intermediate file is :

Argument of string macro function ‘World is our’ is converted into string by the operator # .Now the string constant “World is our” is replaced the macro call function in line number 4.
2. ##

This operator is called token pasting operator. When we use a macro function with various argument then we can merge the argument with the help of ## operator.
#define merge(p,q,r) p##q##r
Void main()
int merge(a,b,c)=45;

Output : 45
Explanation :
Arguments a,b,c in merge macro call function is merged in abc by ## operator .So in the intermediate file declaration statement is converted as :
int abc=45;

Related Links :

1 comment:

  1. 1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 ...
    The three dots are given as a part of the specification. The above pyramid is to be printed when input number 13 is given. Write a program to print the above pyramid.
    pls help me to print the pyramid


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE

More Useful Topics...


History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming

My 1st Program...

void main ()
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();

Next Step...


void main ()
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();