C – Pointers

The C Pointer is a variable that is used to store the memory address as its value. However, to get the memory address of a variable, use the & operator. This means a variable has a unique memory location. This memory location has its own address. To access this address, we use the ampersand i.e., the & operator.

In this lesson, we will discuss the two operators useful to understand the concept of Pointers in C:

  • The Address Operator: Access the address of a variable. Defined by &, the ampersand sign.
  • The Indirection Operator: Access the value of an address. Defined by *, the asterisk sign.

Let us see an example to display the address of variables in C:

Output

Syntax

Above, varName is the pointer variable, whereas datatype is the type.

Declare and create a Pointer

Follow the above syntax and let us see how we can create and declare pointers:

Example

Let us now see an example is to create a pointer variable and point to an integer variable:

Output

C - Enums
C - File Handling
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading