C Language Ch5
C Language Ch5
Unit – 5
Pointer & File structure
Introduction of Memory
Memory is a sequential collection of memory cells, which
are in bytes, associated with their address.
The first address of memory cell is 0, and last address
depends on size of memory.
When we declare any variable in our program, they are
stored in these memory cells. Memory cell (in bytes) Address
0
1
2
.
.
.
65535
Pointer
“Pointer is a variable which can store address of another
variable.”
Pointer is derived data type like array & structure.
Address is a location in in memory where data are stored,
and pointer is used to access that data.
Features or Benefits of Pointer:
(1) pointers are more efficient to handle arrays.
(2) pointer to character string array saves space.
(3) using pointer, C supports Dynamic memory allocation.
(4) They increase the execution speed and thus reduce the
program execution time.
Declaration of pointer:
Data_type *pointer_name;
“*” this is called pointer sign, which shows that the variable is
a pointer variable.
The above declaration tells the compiler that *pointer_name is
a pointer variable, which can store address of type “data_type”.
For example, in int *p, *p is a pointer variable, which can store
address of int type variable.
Initialization of pointer:
Pointer_variable = & variable; Variable A p
Variable Meaning
a Values of a
&a Address of a
*p Value of a
P Address of a