what is micro in c programming.

Could be a abbreviation for microphone or microgram. Could you please be more specificic with your question?

//what would be output of this program.

#include<stdio.h>
#define abc(a) printf("%s=%s",#a,a)
void main()
{
char str[]="uday";
abc(str);
}

What do you mean with the # symbol? Is it the & symbol?

//what would be output of this program.

Why don't you compile it, run it and see for your self what the output is.

what is micro in c programming.

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:

printf("%s=%s","str",str)

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.

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.