What is a pointer in C?

A pointer is a variable which stores the address of another variable. We get the address with & and the value at an address with *.

#include <stdio.h>

int main(void) {
    int n = 10;
    int *p = &n;

    *p = 20;
    printf("%d\n", n);
    return 0;
}

Output:

Output of the above program is

20

Changing *p changed n. See C Pointers.


Learn more about the similar topics:
Tutorials
C Pointers
C Pointer Arithmetic
C Pointer to Pointer
C Pointers and Arrays
C Pointers and Functions
C Dynamic Memory Allocation
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is a pointer in C?
What is a NULL pointer in C?
What is the difference between malloc() and calloc() in C?
What is a memory leak in C and how to avoid it?
What is a dangling pointer in C?
What is the difference between an array and a pointer in C?
What is a void pointer in C?