I am learning C language. I was reading to declare constants. What is the difference between
#define PI 3.1415927
and
float const PI = 3.1415927;
Thanks.
I am learning C language. I was reading to declare constants. What is the difference between
#define PI 3.1415927
and
float const PI = 3.1415927;
Thanks.
 
    
    #define is text replacement. All occurrences of PI in your code will be replaced by 3.1415927 before compilation.
const creates read-only variables. That means you can't assign to them, but you still can't use them as e.g. case labels, because they're not true constants.
