Hello to all.
The technique ( __LINE__ + 1 ) is good ? Because I want the exact line in which the error will be found.Code:
#include <stdio.h>
#define CHECK_ZERO(divisor) \
if( divisor == 0) \
printf("**Attempting to divide by zero on line: %d " \
"of file: %s" , ( __LINE__ + 1 ) , __FILE__)
int main( void )
{
int x,y;
printf("Give x , y : ");
scanf("%d%d" , &x , &y);
CHECK_ZERO(x);
int division = x/y;
printf("%d" , division);
return 0;
}
Another question is ..... Macro may evaluate its arguments more than once ... but a function only once.... what about if we have
Each time i will be evaluated .. foo(1) , foo(2) so forth .. why a function evaluates its arguments only once? I don't understand here.... Is there any example of what we mean when we say that a macro may evaluate its arguments more than once ?Code:
for(int i=0; i<3; i++)
foo(i) ;
Thank you in advance.