KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The scope of #define is till the end of the file. But where does it start from? Basically I tried the following code. #include <stdio.h> #include <stdlib.h> #define pi 3.14 void fun(); int main() { printf("%f \n", pi); #define pi 3.141516 fun(); return 0; } void fun() { printf("%f \n", pi); } The output of the above program comes out to be 3.140000 3.141516 Considering preprocessing for main the value of pi should be 3.141516 and outside main 3.14. This is incorrect but please explain why.
Tags (comma-separated)
Save Edits
Cancel