CODE
#include <stdio.h>
void fun(void)
{
#define fun() i=10
}
int main()
{
int i = 20;
fun();
printf("i = %d\n", i);
return 0;
}
void fun(void)
{
#define fun() i=10
}
int main()
{
int i = 20;
fun();
printf("i = %d\n", i);
return 0;
}
I think that this won't work :
(i guess) we can't put preprocessor directives on a function
If we can , it won't work also , because the compiler or the processor had completed the line :
CODE
fun();
so he won't replace it .
if the preprocessor works in functions i guess this will be the answer
CODE
void fun(void)
{
#define printf("i = %d\n", i) i=0
}
int main()
{
int i = 20;
fun();
printf("i = %d\n", i);
return 0;
}
{
#define printf("i = %d\n", i) i=0
}
int main()
{
int i = 20;
fun();
printf("i = %d\n", i);
return 0;
}
What do you think ???


