Pointers Introduction
Pointers Introduction
Memory Address
• When a variable is created in C, a memory
address is assigned to the variable.
• The memory address is the location of where
the variable is stored on the computer.
• When we assign a value to the variable, it is
stored in this memory address.
• To access it, use the reference operator (&),
and the result represents where the variable is
stored:
• The memory address is in hexadecimal form
(0x..).
• &myAge is often called a "pointer".
• A pointer basically stores the memory address of
a variable as its value.
• To print pointer values, we use the %p format
specifier.
datatype * ptr;
Creating Pointers
void Ptr_pgm()
{
int var = 10;
int main()
{
Ptr_pgm();
return 0;
• Write a program in C to show the basic
declaration of a pointer.
• Write a program in C to demonstrate how to
handle pointers in a program.
• Write a program in C to demonstrate the use of the
&(address of) and *(value at address) operators.