6/7/24, 3:37 PM 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: ++, --,
+, -
Array of pointers: You can define arrays to hold a number of pointers.
Pointer to pointer: C allows you to have pointer on a pointer and so on.
Passing pointers to functions in C: Passing an argument by reference or by address enable
the passed argument to be changed in the calling function by the called function.
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;
printf ("value of a = %d\n", a);
printf ("value of a = %d\n", *(&a));
printf ("value of a = %d\n", *b);
printf ("address of a = %u\n", &a);
printf ("address of a = %d\n", b);
printf ("address of b = %u\n", &b);
printf ("value of b = address of a = %u", b);
return 0;
}
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
For Videos Join Our Youtube Channel: Join Now
Feedback
https://www.javatpoint.com/data-structure-pointer 5/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Help Others, Please Share
Learn Latest Tutorials
Splunk SPSS Swagger Transact-SQL
Tumblr ReactJS Regex Reinforcement
Learning
R Programming RxJS React Native Python Design
Patterns
Python Pillow Python Turtle Keras
Preparation
Aptitude Logical Verbal Ability Interview
Reasoning Questions
Aptitude Verbal Ability
Reasoning Interview Questions
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
Artificial AWS Tutorial Selenium Cloud
Intelligence tutorial Computing
AWS
Artificial Selenium Cloud Computing
Intelligence
Hadoop tutorial ReactJS Data Science Angular 7
Tutorial Tutorial Tutorial
Hadoop
ReactJS Data Science Angular 7
Blockchain Git Tutorial Machine DevOps
Tutorial Learning Tutorial Tutorial
Git
Blockchain Machine Learning DevOps
B.Tech / MCA
DBMS tutorial Data Structures DAA tutorial Operating
tutorial System
DBMS DAA
Data Structures Operating System
Computer Compiler Computer Discrete
Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
Computer Network Compiler Design
Computer Discrete
Organization Mathematics
Ethical Hacking Computer Software html tutorial
Graphics Tutorial Engineering
Ethical Hacking Web Technology
Computer Graphics Software
Engineering
Cyber Security Automata C Language C++ tutorial
tutorial Tutorial tutorial
C++
Cyber Security Automata C Programming
https://www.javatpoint.com/data-structure-pointer 7/8
6/7/24, 3:37 PM Pointer (Data Structures) - javatpoint
Java tutorial .Net Python tutorial List of
Framework Programs
Java Python
tutorial
Programs
.Net
Control Data Mining Data
Systems tutorial Tutorial Warehouse
Tutorial
Control System Data Mining
Data Warehouse
AD
https://www.javatpoint.com/data-structure-pointer 8/8