|
|
|
|
![]() ![]() |
Feb 26 2008, 07:15 PM
Post
#21
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 22 Joined: 20-February 08 Member No.: 58,158 |
CODE #include <stdio.h> 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; } What do you think ??? |
|
|
|
Feb 27 2008, 12:41 AM
Post
#22
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 416 Joined: 26-January 08 Member No.: 56,881 |
printf is a standard function in C. You can't modify it.
Try doing the same thing in c++. |
|
|
|
Apr 30 2008, 01:52 PM
Post
#23
|
|
|
Hail Caesar! ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 5,876 Joined: 21-September 07 Member No.: 50,369 |
code for this program
C Code, Can U Solve This? Easy code in 'C' program to prove pallidrome rule Thanking you, Vikram -question by vikram |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 12th October 2008 - 03:53 PM |