Typically, when we initialise an array, we learn about the,
Memory block, or the RAM space allotted to a variable. That area can be compared to a block.The name of the memory block, which is the name of the variable.the block’s content, which is the variable’s value,The variable’s unique address in memory, which we may access, is the address of the memory block assigned to the variable.
How do pointers work?
A variable that contains the address of another variable is called a pointer. It denotes that the variable is a variable that points to any other variable.This contains the address or memory location of any other variable, despite the fact that it is itself a variable.It can be a pointer of any type, including int, char, array, function, and more.Its size is based on its architectural design.In the C language, pointers can be specified using *. (asterisk symbol).
Therefore, pointers are nothing more than variables that contain the addresses of other variables, and we can access and even modify other variables by using pointers.
The Uses of Pointers
- Using techniques like malloc(), realloc(), calloc(), and free, pointers are utilised to dynamically allocate or deallocate memory ().
- Pointers are used to pass addresses of containers to functions as well as to point to other containers, such as arrays or structs.
- Give a function many values.
- We can supply a function a pointer to a container rather than a copy of the container. The software uses less memory as a result of this.
- Pointers streamline the code and boost efficiency.