What does the following code do in the find.c source code in pset3
const int MAX = 65536;
Does it define a constant MAX with value 65536?
If so, then is this same as writing : #Define MAX 65536
No they are not the same:
#define MAX 65536
:
This tells the compiler to swap all instances of MAX with 65536, it is not not a variable that exists in memory.
const int MAX = 65536
:
This declares a variable MAX
of type int
that contains the value 65536
, the const
keyword tells the compiler that this variable must not and will not be changed, its value is constant for the remainder of its lifetime.
You might want t have a look the links below for more detailed info on this topic.