I have two questions on this part of the code :
- Is this used to calculate the size of the array with the position in memory?
It’s used to calculate the number of items in an array.
sizeof(a) returns the number of bytes that the array occupies. So for example int myArray would occupy 20 bytes because an int occupies 2 bytes.
sizeof(a) returns the size of the first element of the array, so in our int myArray example, it would return 2. Meaning the entire macro returns 20 / 2 which is the number of elements in the array.
2. What is 'a' is some general form to use when defining a variable or a relation?
‘a’ is simple the replacing text in the macro. When you call the macro like this:
The preprocessor converts it to this: