Pointer (Data Structures) - Javatpoint
Pointer (Data Structures) - Javatpoint
Home Data Structure C C++ C# Java SQL HTML CSS JavaScript Ajax
https://www.javatpoint.com/data-structure-pointer 1/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Pointer
Pointer is used to points the address of the value stored anywhere in the computer memory. To
obtain the value stored at the location is known as dereferencing the pointer. Pointer improves the
performance for repetitive process such as:
Traversing String
Lookup Tables
Control Tables
Tree Structures
Pointer Details
Pointer arithmetic: There are four arithmetic operators that can be used in pointers: ++, --,
+, -
Return pointer from functions in C: C allows a function to return a pointer to the local
variable, static variable and dynamically allocated memory as well.
AD
https://www.javatpoint.com/data-structure-pointer 2/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Program
Pointer
#include <stdio.h>
int main( )
{
int a = 5;
int *b;
b = &a;
Output
https://www.javatpoint.com/data-structure-pointer 3/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
value of a = 5
value of a = 5
address of a = 3010494292
address of a = -1284473004
address of b = 3010494296
value of b = address of a = 3010494292
Program
Pointer to Pointer
#include <stdio.h>
int main( )
{
int a = 5;
int *b;
int **c;
b = &a;
c = &b;
printf ("value of a = %d\n", a);
printf ("value of a = %d\n", *(&a));
printf ("value of a = %d\n", *b);
printf ("value of a = %d\n", **c);
printf ("value of b = address of a = %u\n", b);
printf ("value of c = address of b = %u\n", c);
printf ("address of a = %u\n", &a);
printf ("address of a = %u\n", b);
printf ("address of a = %u\n", *c);
printf ("address of b = %u\n", &b);
printf ("address of b = %u\n", c);
printf ("address of c = %u\n", &c);
return 0;
}
https://www.javatpoint.com/data-structure-pointer 4/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Pointer to Pointer
value of a = 5
value of a = 5
value of a = 5
value of a = 5
value of b = address of a = 2831685116
value of c = address of b = 2831685120
address of a = 2831685116
address of a = 2831685116
address of a = 2831685116
address of b = 2831685120
address of b = 2831685120
address of c = 2831685128
← Prev Next →
AD
Feedback
https://www.javatpoint.com/data-structure-pointer 5/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Preparation
Company
Interview
Questions
Company Questions
https://www.javatpoint.com/data-structure-pointer 6/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Trending Technologies
B.Tech / MCA
https://www.javatpoint.com/data-structure-pointer 7/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
AD
https://www.javatpoint.com/data-structure-pointer 8/8