Difference between Arrays and pointers
- An array is a collection of elements of similar data type whereas the pointer is a variable that stores the address of another variable.
- An array size decides the number of variables it can store whereas; a pointer variable can store the address of only one variable in it.
- Arrays can be initialized at the definition, while pointers cannot be initialized at the definition.
- Arrays are static in nature which means once the size of the array is declared, it cannot be resized according to users requirement. Whereas pointers are dynamic in nature, which means the memory allocated can be resized later at any point in time.
- Arrays are allocated at compile time while pointers are allocated at runtime.