POINTERS


Pointer is a memory variable, which can store the address of
            another variable.

            Pointers can point other variables.

            Normally, when we declare some variables, some amount of memory
is allocated for those variables. These address locations can be
pointed by pointers. The address will be in unsigned integer form, ranging
from 0 to 65535. So pointers are always storing unsigned integers only.If
you need to mention any pointer variable you should use the unsigned integer
control string.


            When discussing pointers, we use the following notations.

            &         - address operator
            *          - value at the address operator(Pointer Operator).
            ->         - In-Direction Operator.

            To declare pointer variables

            dataType *PtrVariable;

            eg: int *p;

            Uses

            1. Allows us to refer the memory locations directly.

            2. Improves the program speed

            3. Used in DMA (Dynamic memory allocaiton or Direct Memory Access)

            4. Used in Data Structures/File processing

            5. Arrays/Strings can be accessed thru pointers.

            6. Functions pass by reference is acheived by pointers

Note :

            Variable           Memory Size    Control strings


            int                    2b                    %d or %i
            char                 1b                    %c
            float                 4b              %f
            double             8b              %lf
            long int            4b              %ld
            unsigned int    2b              %u


            Pointer with in Structures:
            ===========================

                        If you need to Access the Structure members by using Pointer
            Variables, By using indirection (->) Operator we can able to access.

            Syntax for Creating Pointer structure variable:

                        struct structure-name *var1,*var2...;

            If you declared any structure variable as a pointer type, then if you
            need to intialize any members, Before initializing you should initialize
            the pointer structure variable.

            Syntax for Accessing members of structure:

                        var-name -> member-name;

No comments: