Macro works similar to a function, but it's execution time is faster than function. Also, macro simply substitutes the value without performing calculatons where as function does calculations. The following example describes the difference between macro and function:
Macro:
#define sq(x) x*x
if you call sq(5+5), the result will be 35 becos macro directly substitutes the value. i.e, in this case, 5+5*5+5 = 35.
Function:
int sq(x)
{
return x*x;
}
if you call sq(5+5) now, the result will be 100, because function calculates the argument value (if it has some calculations) and passes to the operation stack. i.e, in this case sq(5+5) will become sq(10) before passing to return x*x.
Hope this clears. Please let me know, if anybody know more about this