Get Answers to all your Questions

header-bg qa

What is a pointer in C and how can create a pointer

Answers (1)

best_answer

Pointer in C is a variable that has the direct address of the memory location of another variable.

We can create a pointer in C by: 

  • Defining a pointer value. 
  • Assigning the address of a variable to a pointer and
  • finally accessing the value at the address available in the pointer variable

This can be achieved by operator * which returns the Value of the variable located at that address. 

Below is an example of pointer: 

int  var = 20;   /* actual variable declaration */

 int  *ip;        /* pointer variable declaration */

ip = &var;  /* store address of var in pointer variable*/

 

Posted by

Deependra Verma

View full answer