|
INTERVIEW QUESTIONS
C
FUNCTIONS IN C
DETAILS
Question: Advantages of a macro over a function ?
Answer: Macro gets to see the Compilation environment, so it can expand __ __TIME__ __FILE__ #defines. It is expanded by the preprocessor.
For example, you can’t do this without macros #define PRINT(EXPR) printf( #EXPR “=%d ”, EXPR)
PRINT( 5+6*7 ) // expands into printf(”5+6*7=%d”, 5+6*7 );
You can define your mini language with macros: #define strequal(A,B) (!strcmp(A,B))
Macros are a necessary evils of life. The purists don’t like them, but without it no real work gets done.
|
|
|
Category |
Functions in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7372 users |
Added on |
9/18/2014 |
Views |
68513 |
Rate it! |
|
|
Question:
Advantages of a macro over a function ?
Answer:
Macro gets to see the Compilation environment, so it can expand __ __TIME__ __FILE__ #defines. It is expanded by the preprocessor.
For example, you can’t do this without macros #define PRINT(EXPR) printf( #EXPR “=%d ”, EXPR)
PRINT( 5+6*7 ) // expands into printf(”5+6*7=%d”, 5+6*7 );
You can define your mini language with macros: #define strequal(A,B) (!strcmp(A,B))
Macros are a necessary evils of life. The purists don’t like them, but without it no real work gets done. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the difference between printf() and sprintf() ?
|
View Answer
|
|
What is the code for clrscr() function?
|
View Answer
|
|
How to use the cprintf,cscanf,sscanf,sprintf,vsscanf,vsprintf,vscanf & vprintf?
|
View Answer
|
|
How to convert decimal to octal and hexadecimal in c program?
|
View Answer
|
|
How to use floodfill() function and what is the use of kbhit?
|
View Answer
|
|
Write a program with out using main() function?
|
View Answer
|
|
Can there be at lest some solution to determine the number of arguments passed to a variable argument list function?
|
View Answer
|
|
What do the functions atoi(),itoa()and gctv()do?
|
View Answer
|
|
How would you use bsearch()function to search a name stored in array of pointers to string?
|
View Answer
|
|
How would you use the functions sin(),pow(),sqrt()?
|
View Answer
|
|
how would you use the functions memcpy(),memset(),memmove()?
|
View Answer
|
|
How would you use the functions randomize()and random()?
|
View Answer
|
|
How would you use the functions randomize()and random()?
|
View Answer
|
|
what is the difference between the functions rand(),random(),srand() and randomize()?
|
View Answer
|
|
Can you use the function fprintf()to display the output on the screen?
|
View Answer
|
|
How to see return value of main function?
|
View Answer
|
|
How to write a program in c to print its own code?
|
View Answer
|
|
What is the function of c?
|
View Answer
|
|
1. what is a difference between printf and cout . and why printf called a function and cout object as both are used to print data?
|
View Answer
|
|
How to print a statement without using printf() in c?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Functions in C Interview Questions & Answers - Exam Mode /
Learning Mode
|