what does i##j mean in macro definition of a program

Recommended Answers

All 2 Replies

It's the preprocessor's pastie operator. It takes two tokens and concatenates them into a single token. For example:

#include <stdio.h>

#define PASTIE(prefix, var) prefix ## var

int main(void)
{
    char const* strFoo = "foo!";
    
    puts(PASTIE(str, Foo));
    
    return 0;
}

Neither str nor Foo are meaningful by themselves, but when combined they match the variable name strFoo, so this code both compiles and prints "foo!" to stdout.

It's the preprocessor's pastie operator. It takes two tokens and concatenates them into a single token. For example:

#include <stdio.h>

#define PASTIE(prefix, var) prefix ## var

int main(void)
{
    char const* strFoo = "foo!";
    
    puts(PASTIE(str, Foo));
    
    return 0;
}

Neither str nor Foo are meaningful by themselves, but when combined they match the variable name strFoo, so this code both compiles and prints "foo!" to stdout.

thnxx!! got it..:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.