SlideShare a Scribd company logo
5
Most read
6
Most read
15
Most read
Pointer in c
Pointer in c
What is a pointer?
Pointer is a kind of variable that can hold the address of a
variable. The sign ‘&’ used to refer somethings address and
‘*’ used to refer the value of a pointer variable. ‘%p’, ‘%x’,
‘%X’, ‘%u’ are the format specifier of pointer.
address
content
address
&*pointer
Declaring a pointer variable
General syntax of pointer declaration is,
data-type *pointer_name;
Data type of pointer must be same as the variable, which the
pointer is pointing. void type pointer works with all data
types, but isn't used often.
Example Description
Int* p p is a pointer to an integer.
Int** p p is a pointer to a pointer to an integer.
Int*[] p p is a single-dimensional array of pointers to
integers.
char* p p is a pointer to a char.
void* p p is a pointer to an unknown type.
Initialization of Pointer variable
Pointer Initialization is the process of assigning address of a
variable to pointer variable. Pointer variable contains address
of variable of same data type. In C language address
operator ‘&’ is used to determine the address of a variable.
The ‘&’ returns the address of the variable associated with it.
Pointer variable always points to same type of data.
float a;
int *ptr;
ptr = &a; //ERROR, type mismatch
int a = 10 ;
int *ptr ; //pointer declaration
ptr = &a ; //pointer initialization
or,
int *ptr = &a ; //initialization and declaration together
Dereferencing of Pointer
Once a pointer has been assigned the address of a variable.
To access the value of variable, pointer is dereferenced, using
the indirection operator ‘*’.
int a,*p;
a = 10;
p = &a;
printf("%d",*p); //this will print the value of a.
printf("%d",*&a); //this will also print the value of a.
printf("%u",&a); //this will print the address of a.
printf("%u",p); //this will also print the address of a.
printf("%u",&p); //this will also print the address of p.
An Example of pointer
Pointer of pointers
A pointer to a pointer is a chain of pointers. Normally, a
pointer contains the address of a variable. A variable that is
a pointer to a pointer must be declared as such. This is
done by placing an additional asterisk in front of its name.
For example, an ‘int’ type pointer to pointer - **p1, ***p2,
****p3 etc.
When we define a pointer to a pointer, the first pointer
contains the address of the second pointer, which points to
the location that contains the actual value as shown below.
Pointer Pointer Variable
Address Address Value
When we define a pointer to a pointer, the first pointer
contains the address of the second pointer, which points to
the location that contains the actual value as shown below.
An example of pointer of pointers
Given Task
Pointer in c
THANK YOU!

More Related Content

PPTX
Pointer in c
PPTX
Database Management System ppt
PPTX
Pointers in C Programming
PDF
Introduction of Kubernetes - Trang Nguyen
PPTX
Basic computer ppt
PDF
C Pointers
PPTX
Interrupts in 8051
PPTX
Insertion Sorting
Pointer in c
Database Management System ppt
Pointers in C Programming
Introduction of Kubernetes - Trang Nguyen
Basic computer ppt
C Pointers
Interrupts in 8051
Insertion Sorting

What's hot (20)

PPTX
Pointer in c program
PPTX
Pointer in C
PPTX
Pointers in c++
PDF
Pointers in C
PPT
Pointers C programming
PPTX
Pointer in C++
PPTX
Pointers in c++
PPTX
Presentation on pointer.
PPTX
Pointer arithmetic in c
PDF
Pointers
PPTX
Pointers in c - Mohammad Salman
PPT
pointers
PPTX
Pointers in C Language
PPTX
Union in C programming
PPTX
Operator overloading
PPTX
PPT
Pointers in c
PPTX
Types of Constructor in C++
PPTX
Pointers and Structures.pptx
PDF
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
Pointer in c program
Pointer in C
Pointers in c++
Pointers in C
Pointers C programming
Pointer in C++
Pointers in c++
Presentation on pointer.
Pointer arithmetic in c
Pointers
Pointers in c - Mohammad Salman
pointers
Pointers in C Language
Union in C programming
Operator overloading
Pointers in c
Types of Constructor in C++
Pointers and Structures.pptx
EASY UNDERSTANDING OF POINTERS IN C LANGUAGE.pdf
Ad

Viewers also liked (16)

PPTX
System of linear equation - SLE
PPTX
CSE240 Pointers
PPT
Pointers - DataStructures
PPT
Pointers in C
PPTX
C++ Pointers
PDF
Adelgazar con los súperalimentos
PDF
FinePrint
PPTX
Олеся Боровець"Гроші"
ODP
The Neo- Classical Literature
PPTX
99度培训:如何讲故事
PPTX
Ejercicio de lectura compresiva
DOCX
Campeonato brasileiro – artilharia
PPTX
Fase de ejecución actividad colaborativa grupo10
PPTX
Carreras universitarias
PPTX
System of linear equation - SLE
CSE240 Pointers
Pointers - DataStructures
Pointers in C
C++ Pointers
Adelgazar con los súperalimentos
FinePrint
Олеся Боровець"Гроші"
The Neo- Classical Literature
99度培训:如何讲故事
Ejercicio de lectura compresiva
Campeonato brasileiro – artilharia
Fase de ejecución actividad colaborativa grupo10
Carreras universitarias
Ad

Similar to Pointer in c (20)

PPT
SPC Unit 3
PPTX
pointers.pptx
PPTX
Pointer in c
PPTX
Pointer in c
PPTX
PPS-POINTERS.pptx
PPTX
Lecture 7_Pointer.pptx FOR EDUCATIONAL PURPOSE
PPTX
pointers of the programming in c most efficient.pptx
PPT
Pointer introduction day1
PDF
Pointers-Computer programming
PDF
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
PPT
Lect 9(pointers) Zaheer Abbas
PPT
Lect 8(pointers) Zaheer Abbas
PPTX
4 Pointers.pptx
PPTX
UNIT 4 POINTERS.pptx pointers pptx for basic c language
PDF
Pointers
PPTX
NRG 106_Session 6_String&Pointer.pptx
PPTX
Unit-I Pointer Data structure.pptx
PDF
Lk module5 pointers
PDF
Pointers in C language
SPC Unit 3
pointers.pptx
Pointer in c
Pointer in c
PPS-POINTERS.pptx
Lecture 7_Pointer.pptx FOR EDUCATIONAL PURPOSE
pointers of the programming in c most efficient.pptx
Pointer introduction day1
Pointers-Computer programming
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
Lect 9(pointers) Zaheer Abbas
Lect 8(pointers) Zaheer Abbas
4 Pointers.pptx
UNIT 4 POINTERS.pptx pointers pptx for basic c language
Pointers
NRG 106_Session 6_String&Pointer.pptx
Unit-I Pointer Data structure.pptx
Lk module5 pointers
Pointers in C language

More from Imamul Kadir (6)

PPTX
Mastering the Heatwave: An Exhaustive Guide to Thriving Amidst Excessive Temp...
PPTX
3D Display and Color Model
PPTX
Autonomous Enemy Locator AI Agent
PPTX
Floyd Warshall Algorithm
PPTX
Cricket
PPTX
Role playing on my favorite person
Mastering the Heatwave: An Exhaustive Guide to Thriving Amidst Excessive Temp...
3D Display and Color Model
Autonomous Enemy Locator AI Agent
Floyd Warshall Algorithm
Cricket
Role playing on my favorite person

Recently uploaded (20)

PDF
composite construction of structures.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
DOCX
573137875-Attendance-Management-System-original
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Well-logging-methods_new................
PPT
Mechanical Engineering MATERIALS Selection
PDF
Digital Logic Computer Design lecture notes
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Sustainable Sites - Green Building Construction
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
composite construction of structures.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
573137875-Attendance-Management-System-original
Arduino robotics embedded978-1-4302-3184-4.pdf
Well-logging-methods_new................
Mechanical Engineering MATERIALS Selection
Digital Logic Computer Design lecture notes
CYBER-CRIMES AND SECURITY A guide to understanding
Sustainable Sites - Green Building Construction
Strings in CPP - Strings in C++ are sequences of characters used to store and...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Construction Project Organization Group 2.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CH1 Production IntroductoryConcepts.pptx
Structs to JSON How Go Powers REST APIs.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Internet of Things (IOT) - A guide to understanding
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf

Pointer in c

  • 3. What is a pointer? Pointer is a kind of variable that can hold the address of a variable. The sign ‘&’ used to refer somethings address and ‘*’ used to refer the value of a pointer variable. ‘%p’, ‘%x’, ‘%X’, ‘%u’ are the format specifier of pointer.
  • 5. Declaring a pointer variable General syntax of pointer declaration is, data-type *pointer_name; Data type of pointer must be same as the variable, which the pointer is pointing. void type pointer works with all data types, but isn't used often. Example Description Int* p p is a pointer to an integer. Int** p p is a pointer to a pointer to an integer. Int*[] p p is a single-dimensional array of pointers to integers. char* p p is a pointer to a char. void* p p is a pointer to an unknown type.
  • 6. Initialization of Pointer variable Pointer Initialization is the process of assigning address of a variable to pointer variable. Pointer variable contains address of variable of same data type. In C language address operator ‘&’ is used to determine the address of a variable. The ‘&’ returns the address of the variable associated with it.
  • 7. Pointer variable always points to same type of data. float a; int *ptr; ptr = &a; //ERROR, type mismatch int a = 10 ; int *ptr ; //pointer declaration ptr = &a ; //pointer initialization or, int *ptr = &a ; //initialization and declaration together
  • 8. Dereferencing of Pointer Once a pointer has been assigned the address of a variable. To access the value of variable, pointer is dereferenced, using the indirection operator ‘*’. int a,*p; a = 10; p = &a; printf("%d",*p); //this will print the value of a. printf("%d",*&a); //this will also print the value of a. printf("%u",&a); //this will print the address of a. printf("%u",p); //this will also print the address of a. printf("%u",&p); //this will also print the address of p.
  • 9. An Example of pointer
  • 10. Pointer of pointers A pointer to a pointer is a chain of pointers. Normally, a pointer contains the address of a variable. A variable that is a pointer to a pointer must be declared as such. This is done by placing an additional asterisk in front of its name. For example, an ‘int’ type pointer to pointer - **p1, ***p2, ****p3 etc. When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value as shown below.
  • 11. Pointer Pointer Variable Address Address Value When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value as shown below.
  • 12. An example of pointer of pointers