- Accessing array elements: Pointers are used in traversing through an array of integers and strings. The string is an array of characters which is terminated by a null character ‘\0’.
- Dynamic memory allocation: Pointers are used in allocation and deallocation of memory during the execution of a program.
- Call by Reference: The pointers are used to pass a reference of a variable to other function.
- Data Structures like a tree, graph, linked list, etc.: The pointers are used to construct different data structures like tree, graph, linked list, etc.
Sandhya Answered question June 28, 2023
In C, the pointer is a variable used for storing the address of a variable. The variable can be of any type such as int, char, array, etc. The pointer size depends on the computer architecture, however, for a 32-bit system, the pointer used is 2 bytes.
Sandhya Answered question June 28, 2023