7

Please tell me the answer with explanation:

#define f(g,h) g##h

main(){
  printf("%d",f(100,10));
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Rishabh Jain
  • 79
  • 1
  • 1
  • 2
  • 4
    possible duplicate of [Reading Zend Engine API code: What does ## (double hash) means?](http://stackoverflow.com/questions/653466/reading-zend-engine-api-code-what-does-double-hash-means). Other dups [here](http://stackoverflow.com/questions/7880058/double-hash-before-parameter-in-function-call),[here](http://stackoverflow.com/questions/15885213/use-of-double-hash-in-c) and [here](http://stackoverflow.com/questions/9059772/what-do-two-adjacent-pound-signs-mean-in-a-c-macro) – Spikatrix Apr 11 '15 at 12:18
  • 1
    this is the macro concatenation operator, it just appends the string values of g and h – amdixon Apr 11 '15 at 12:19
  • Just execte your code and you will see – Dabo Apr 11 '15 at 12:20

2 Answers2

13

## is used to concatenate whatever is before the ## with whatever is after it. It is used for concatenation.

You can check the reference for details

A ## operator between any two successive identifiers in the replacement-list runs parameter replacement on the two identifiers (which are not macro-expanded first) and then concatenates the result. This operation is called "concatenation" or "token pasting".

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
2

Here is a useful duplicate - What does ## in a #define mean?

Example

For

  //Definition
  #define ArgArg(x, y)     x##y

  //Example
  ArgArg(lady, bug) -> "ladybug"
J-Dizzle
  • 4,861
  • 4
  • 40
  • 50