You are on page 1of 14

Introduction to Computer

Programming (ICP)

SAADIA BANO
Lecturer
Comsats Institute of Information
Technology
Department of Computer Science,
Sahiwal
Memory and references
In computing memory refers to the computer hardware device that stores
information.
Computer memory is a collection of different consecutive memory locations.
each location have a unique identity known as its address.
Variable declaration associates variable name, its type, its memory address.
The actual address of variable can be displayed by using reference
operator(&).
Reference operator is also known as address operator.
Pointers and pointer declaration
Pointer is a variable that is used to store memory address.
Pointer is declared same as variable. Asterisk * is used in declaring that
indicates that variable is a pointer.
Syntax: data type *pointer name;
Int *p;
Float *p1,*p2;
Prog:1
Void pointer
To store any type of variable address void is use.
The type of variable pointer restricts it to use specific data type.
E.g.
Int pointer will store address of only integer variables
Char pointer will store address of char type
Prog:2
Dereference operator
Pointer initialization
C++ dose not initialize variables automatically, so a pointer variable should
be initialized.
The process of assigning address to a pointer at the time of declaration is
known as pointer initialization.
Pointer can be initialized to ant memory valid memory address or as null or 0
value.
Pointers and array
Pointer and strings
Array of pointer
Pointers and functions
The
End

You might also like