what is differnence b/w macro & functions

Answer Posted / babitha

macro: one line function;not having any return type and
argument so it would not report error even if any
misbehaves in fnction;not having return statement;
macros would be replaced by that functions/value where ever
macro name presents;if we need any later change in funcions
then modifing only at macro is neccssary, sicne it is
replacing wherever macro name presents.

functions:we would recieve error if the function call and
function prototypes are mismatch;xplicitly it should have
one return statement if the retrun type of fucntion is
aother than void;control from main function would jump to
function defintion of called fucntion if that function is
called rather than replacing the function;it may have moe
than one line function.If we want later change i fucntion
execution,then we need to modify on function prototype(if
modified),fucntion defintion and whereever that function is
called.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you obtain the current time and difference between two times?

731


What are the back slash character constants or escape sequence charactersavailable in c?

687


I need a sort of an approximate strcmp routine?

662


What is the difference between typedef struct and struct?

602


How many parameters should a function have?

669






What is a stream?

652


Can you mix old-style and new-style function syntax?

665


Tell me what is the purpose of 'register' keyword in c language?

620


Why functions are used in c?

588


Can you add pointers together? Why would you?

647


What is property type c?

606


Tell me what are bitwise shift operators?

659


If fflush wont work, what can I use to flush input?

617


Is null valid for pointers to functions?

614


State the difference between realloc and free.

636