Application of Pointers in C

Q1. What are the uses of a pointer?

Answer:

Pointer is used in the following cases
             i) It is used to access array elements
            ii) It is used for dynamic memory allocation.
           iii) It is used in Call by reference
           iv) It is used in data structures like trees, graph, linked list etc.

Q2. Are pointers integer?

Answer:

No, pointers are not integers. A pointer is an address and a positive number.

Q3. What does the error ‘Null Pointer Assignment’ means and what causes this error?

Answer:

As null pointer points to nothing so accessing a uninitialized pointer or invalid location may cause an error.

Q4. How pointer variables are initialized?

Answer:

Pointer variables are initialized by one of the following ways.
             I. Static memory allocation
            II. Dynamic memory allocation

Q5. What is pointer to a pointer?

Answer:

If a pointer variable points another pointer value. Such a situation is known as a pointer to a
pointer.
Example:
   int *p1,**p2,v=10;
   P1=&v; p2=&p1;
   Here p2 is a pointer to a pointer

Q6. What is an array of pointers?

Answer:

If the elements of an array are addresses, such an array is called an array of pointers.



Applications of Pointers in C

Pointers in C are variables that are used to store the memory address of another variable. Pointers allow us to efficiently manage the memory and hence optimize our program. In this article, we will discuss some of the major applications of pointers in C.

Prerequisite: Pointers in C.

Similar Reads

C Pointers Application

The following are some major applications of pointers in the C programming language:...

FAQs on Application of Pointers in C

Q1. What are the uses of a pointer?...