   ## concatenating macro directive
  I'm reading a good article on macros, but I can't seem to understand the ## preprocessor macro directive. It's supposed to concatenate something, but I don't understand how, or what purpose it serves.Here's my current code:#include <iostream>#define concatenate(arg1, arg2) arg1 ## arg2int main(){    int concatenate(fire, fly);    concatenate(fire, fly) = 1;   std::cout << concatenate(fire, fly) << std::endl;    return 0;}    According to the article, the preprocessed code will look something like this:main(){int firefly ;firefly = 1;printf("%d \n",firefly );}I still can't understand what's going on though, or why! :S Help, please?   
  The ## operator pastes a macro token onto another token, eg:#define READ(size) Read##sizeThis macro expands as follows:READ(Byte) => ReadByteREAD(Word) => ReadWordetc;Quote:Original post by Afr0m@nI still can't understand what's going on though, or why! :S Help, please?as the article (and you) state, the ## derective combines two arguments into one.that is, in your example, the ## derective combines fire and fly to make firefly.the way preprocessor derectives work in general is that they take effect before compilation, so that and macro called in your code is replaced by the actual body of the macro before compile time.hence, when concatenate(fire, fly) gets precompiled, that macro call is replaced with the concatination of the two words into firefly, hence, concatenate(fire, fly) -> fireflysimilarly, if you had the macro:#define SAFEDEL(ptr) if(ptr) { delete ptr; ptr = NULL; }and called it in this code:void foo(void){ myClass* pClassInstance = new myClass; SAFEDEL(pClassInstace)}it would get precompiled into:void foo(void){ myClass* pClassInstance = new myClass; if (pClassInstance) { delete pClassInstance; pClassInstance = NULL; }}as far as why ## may be usefull, the article you link to states: "This is useful in forming unique variable names within macros."   ;  Thanks guys! I think I know what happens now, and why to use it. :)   