I believe the term you are going for is macro, not micro. A macro is a piece of code that gets replaced by another piece of code at compile time, before the compilation process proper begins. This is called macro expansion, and in C is mostly used as a way of getting the effect of a function without as much overhead. In C and C++, a macro is defined by a pre-processor statement, #define, which indicates that the macro name and parameter list immediately following the #define should be expanded to the . For example, the simple macro:
#define PI 3.1415
... in the following code
area = PI * r * r;
is textually expanded to
area = 3.1415 * r * r;
Note that this is an exact replacement of the string 'PI' with the string '3.1415' in the code itself; the compiler doesn't see the actual PI, just the 3.1415. This is important because there is no type checking or other protection in macros; if you had a macro:
#define SQUARE(x) x * x
and applied it to a sum,
area = PI * SQUARE(2 + 12);
you would get
area = 3.1415 * 2 + 12 * 2 + 12;
which almost certainly isn't what you intended.
For the macro you showed, things get a little more complicated, because it uses the dtringifying operator, #. What this does is cause the macro argument to be inserted as a C string into the macro expansion. The macro expansion for the invocation given would be:
Thus, for the code above, the result would be to print out, str == uday.
BTW, the main() function should always be delcared a returning an int value, and should return zero for a successful completion. The use of void main() was legal in older C code, but was never standard.
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...