Both declarations are equivalent. 'const int * const ptr' and 'int const * const ptr' declare a constant pointer to a constant integer. The first const makes the integer constant, the second const makes the pointer constant.
#include
int main() {
int a = 5;
printf("%d %d %d", a++, ++a, a);
return 0;
}
This code contains undefined behavior because variable 'a' is modified multiple times (a++, ++a) without intervening sequence points in the same expression. The order of evaluation is unspecified, making the result compiler-dependent.
A B-tree of order m has a maximum of m children per node, which means it can have a maximum of (m-1) keys.
Each node can have between ⌈m/2⌉ and m children (for non-leaf nodes), ensuring balance. B-trees are commonly used in database indexing and file systems because they minimize disk I/O operations through their multi-level structure and balanced properties.
The volatile keyword tells the compiler that a variable's value may change at any time (due to external factors like hardware registers, signal handlers, or multi-threading) and should be read from memory every time it's accessed, rather than being optimized by the compiler or cached in a register.
struct demo {
unsigned int a : 5;
unsigned int b : 3;
unsigned int c : 4;
unsigned int d : 7;
};
Bit fields in C are packed into the smallest integral type that can accommodate them.
Here, a(5) + b(3) + c(4) + d(7) = 19 bits total.
Since 19 bits exceed 16 bits but fit within 32 bits, the compiler allocates 4 bytes (32 bits) for this structure, following standard packing rules.