> Hmm.. so we can declare define in a function like this!
No, you're not defining in a function. The preprocessor looks for # lines and processes them without regard to the code. So the preprocessor effectively sees the code as
blah blah blah
#define one variable - aha, a #define statement, so let's let "one" be defined as "variable", whatever that means
#define two variable - same again
printf("%d\n",one); - aha, there's a "one" here, we know what that is, so we'll change this line from 'printf("%d\n",one);' (whatever that means) to 'printf("%d\n",variable);' (whatever that means)
Oh, end of file. OK, I'll stop then.
So the preprocessor is REALLY DUMB. Also, after processing a # line it removes it from the source file and the compiler doesn't see it. So what the compiler sees is this:
void test(int *variable) // rename variable to anything you like, it has no effect
So that's what I meant when I said test() does nothing. You can see clearly here why it does nothing - because it contains no code.
As for whether or not it is good practice to do this, well I'd say it depends on the code. In this case it's confusing for the OP because he seems to think the "one" and "two" defines have something to do with the parameter passed into test(). If you have good reason to specify a #define within a function then do so, and usually what you would do is to add a #undef towards the end of that function so that the define doesn't hang around and cause problems for other people.
> what makes me confused is that if we are using a Macro then why is it required to make is Local to a function alone
You are quite right to be confused by that, because it's nonsense. You CANNOT make a #define local to a function, because the preprocessor does not take the language into account.
> I did not find this correct...
Sorry, I haven't got a clue what you're asking here. Macros are replaced at compile time - correct. The value of variable passed into test() is defined at runtime. "how do we explain..." - that's the bit I don't understand. What exactly needs explaining?