Академический Документы
Профессиональный Документы
Культура Документы
com)
Downloaded From : www.c4cpp.co.nr
Introduction
Definition: Pointer is a variable which stores address of another variable.
To understand this definition properly, let us separate it into two statements:
1. Pointer is a variable.
2. It stores address of another variable.
Consider the first statement, it means that a pointer is a variable like any
other variable such as i in the statement int i, f in the statement float f, c in
the statement char c etc. Now consider the second statement, it states
pointer stores address of another variable. And this is the difference between
pointer and an ordinary variable. An ordinary variable stores value such as a
whole number, real number, a character etc, where as a pointer stores
address of another variable.
Null pointers are useful for indicating special cases such as no next
pointer in the final node of a linked list, or as an error indication from
functions returning pointers.
Void pointers (void *) also exist and point to objects of unknown type, and
can therefore be used as "generic" data pointers. Since the size and type
of the pointed-to object is not known, void pointers cannot be
dereference, nor is pointer arithmetic on them possible, although they can
easily be (and in fact implicitly are) converted to and from any other
object pointer type.