---
title: "What is a pointer in C, and how is it used to manipulate memory addresses?"  
description: "What is a pointer in C, and how is it used to manipulate memory addresses?"  
author: "Utpal Vishwas"  
published: 2023-04-21  
updated: 2023-04-28  
canonical: https://www.mindstick.com/forum/157953/what-is-a-pointer-in-c-and-how-is-it-used-to-manipulate-memory-addresses  
category: "C Language"  
tags: ["programming language", "programs"]  
reading_time: 3 minutes  

---

# What is a pointer in C, and how is it used to manipulate memory addresses?

What is a [pointer in C](https://answers.mindstick.com/qa/104680/what-is-a-pointer-in-c), and how is it used to manipulate [memory](https://www.mindstick.com/blog/300050/what-causes-sudden-memory-loss) addresses?

## Replies

### Reply by Krishnapriya Rajeev

A pointer is a variable that “points to” the address of a variable, or a memory location. In C programming, pointers are considered to be one of the core concepts that allow us to access memory at the lowest level, as well as allow for dynamic memory allocation.

Since a pointer can store the address of another variable, we can use them to access as well as modify the data in that memory location.

The syntax of pointers in C is as follows:

```plaintext
int a = 30;
int *ptr = &a;			// pointer to address of a
printf("%d", a);

// Output = 30
```

The asterisk (*) here is known as the *dereferencing operator*, or the *indirection operator*.

We can use pointers to change the data stored at a memory location as follows:

```plaintext
*ptr = 40;
printf("%d", a);

// Output = 40
```

### Reply by Aryan Kumar

In C, a [pointer](https://www.mindstick.com/articles/11/pointers) is a variable that stores the memory address of another variable. It allows us to indirectly access and manipulate the value of the variable it points to.

To declare a pointer in C, you use the ***** (asterisk) symbol. Here's an example:

```c
int x = 5;
int* ptr = &x;
```

In this example, we declare a variable **x** and assign it the value of 5. We also declare a pointer **ptr** that points to the memory address of **x**. The **&** (ampersand) symbol is used to get the address of **x**.

Once we have a pointer, we can use the ***** symbol (dereference operator) to access the value stored at the memory address pointed to by the pointer. Here's an example:

```c
int y = *ptr;
```

In this example, we use the ***** symbol to get the value stored at the memory address pointed to by **ptr** and assign it to a new variable **y**. In this case, **y** would be equal to 5.

Pointers can also be used to manipulate memory addresses directly. For example, we can use pointer arithmetic to increment or decrement the memory address pointed to by a pointer. Here's an example:

```c
int arr[5] = {1, 2, 3, 4, 5};
int* ptr = arr;

// Increment the pointer by 2
ptr += 2;

// The value pointed to by ptr is now 3
int x = *ptr;
```

In this example, we declare an array **arr** and a pointer **ptr** that points to the first element of the array. We then use pointer arithmetic to increment **ptr** by 2, so that it now points to the third element of the array. We can then use the ***** symbol to get the value stored at the memory address pointed to by **ptr**.

Pointers can be powerful tools in C, but they require careful management to avoid memory leaks and other issues. It's important to always initialize pointers to point to valid memory addresses, and to avoid dereferencing null pointers.


---

Original Source: https://www.mindstick.com/forum/157953/what-is-a-pointer-in-c-and-how-is-it-used-to-manipulate-memory-addresses

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
