Pointers in C - C Pointers



 c pointers

Learn C - C tutorial - c pointers - C examples - C programs

Pointers

  • A pointer is a variable which contains the address in memory of another variable. We can have a pointer to any variable type.
  • The unary or monadic operator & gives the “address of a variable”.
  • A pointer references a location in memory, and the value stored at that location is known as dereferencing a pointer.
  • The indirection or dereference operator * gives the “contents of an object pointed to by a pointer”.

Syntax


int *pointer;   // declaring  pointer
 c pointers

Learn C - C tutorial - c pointers - C examples - C programs

Sample Code

#include <stdio.h>
int main()
{
    int x=10;//integer variable
    int *ptrX;//integer pointer
    ptrX=&x;
    printf("Value of x: %d\n",*ptrX);
    return 0;
}

Output

Value of x: 10


View More Quick Examples


Related Searches to Pointers in C - C Pointers