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
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.