The first one defines PI as a macro. The second one is a constant variable.

The constant float variable takes 4 byte of memory in the data section of the executable only once.

The macro however does not take any memory during declaration but it takes 4 bytes each time PI is assigned to a variable or used in an expression.

float f;
f = (float)PI;

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

malloc vs calloc, NULL pointer, enum type, macro, macro vs constant, enum vs macro, macro vs typedef, debug builds, debug macros,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan