Creating const pointer arguments to functions
Examples of const variable declaration
Here are some other examples of
const variable declaration:
const double pi = 3.14159;
double x = 1.5;
const double *d_p1 = π //legal
double *d_p2 = &x; //legal
const double *d_p2 = &3.1; //illegal:3.1 is not an lvalue
pi = 3.141596; //illegal: pi cannot be modified
d_p1 = &x; //legal: safe conversion
d_p2 = π //illegal: would allow a const to be modified through a non-const pointer
You can write integer values in hexadecimal form to base 16. The digits in a hexadecimal number are the equivalent of decimal values 0 to 15, and they are represented by 0 through 9 and A though F (or a through f).
Because there needs to be a way to distinguish between 9910 and 9916, hexadecimal numbers are written with the prefix 0x or 0X. You would therefore write 9916 in your program as 0x99 or as 0X99. Hexadecimal constants can also have a suffix.
Here are some examples of hexadecimal constants:
0xFFFF 0xdead 0xfade 0xFade 0x123456EE 0xafL 0xFABABULL
The last example is of type unsigned long long, and the second to last example is of type long.
Hexadecimal constants are most often used to specify bit patterns, because each hexadecimal digit corresponds to four bits. Two hexadecimal digits specify a byte.
The bitwise operators are usually used with hexadecimal constants that define masks.
If you are unfamiliar with hexadecimal numbers, just remember they are a number system which uses 16 as a base.
An octal value is a number to base 8. Each octal digit has a value from 0 to 7, which corresponds to three bits in binary.
Octal values originate from the days long ago when computer memory was in terms of 36-bit words, so a word was a multiple of three bits. Thus, a 36-bit binary word could be written as 12 octal digits.
Octal constants are rarely used these days, but you need to be aware of them so you do not specify an octal constant by mistake. An integer constant that starts with a zero, such as 014, will be interpreted by your compiler as an octal number.
Thus, 014 is the octal equivalent of the decimal value 12. If you meant it to be the decimal value 14, it is obviously wrong, so do not put a leading zero in your integers unless you really want to specify an octal value.
There is rarely a need to use octal values.