Entrance Exams
Govt. Exams
free(NULL) is safe in C and does nothing. This is by design to prevent errors when freeing pointers.
const after * means the pointer address cannot change, but the data it points to can be modified.
Pointer arithmetic scales by data type size. p + 2 moves 2 * sizeof(int) bytes forward, pointing to arr[2].
NULL is explicitly set to address 0, while wild pointers contain garbage values from uninitialized memory.
Void pointers cannot perform pointer arithmetic (++, --, +n) directly. They must be cast to a specific type first.
q points to p, p points to x. **q dereferences twice: first gets p's value (address of x), second gets x's value (10).
In 64-bit systems, pointers are 8 bytes (64 bits) regardless of the data type they point to.
Double pointer (int **ptr) is the correct syntax for pointer to pointer. Single & is used in C++ references, not C.
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", sizeof(p));
p is a pointer, so sizeof(p) returns pointer size (8 bytes on 64-bit, 4 on 32-bit), not array size.
int arr[5];
arr decays to pointer to first element (int*). &arr is pointer to whole array (int(*)[5]). Pointer arithmetic differs.