Thursday, February 11, 2016

Pointer Concept in C

******************************Pointer Concept in C***********************************

Pointer is a variable which store the address of anything. Pointer is very important concept in C language.

We have to learn pointer do anything about C as well as C++ language.  We can fetch the address using pointer do anything else in a computer system. We can directly store the address in pointer variable and changing value of that address.

In that power, pointer is a harmful concept in Computer System. To avoid this problem in Java, Java does not use the pointer concept. But ignore this problem pointer is very helpful
concept in C language.

In C language there are three types of datatypes such as,

1) Primitive datatypes like Integer, Character, single-point precision (float) , double-point precision(double) and not value(void)
2) Derived Datatypes like Array, Pointer and function.
3) User-defined Datatypes like Structure, Union and Enumeration.

Pointer is a derived datatype. According to the old (Real mode) Operating System  there is three types of pointer such as
1) far pointer
2) huge pointer
3) near pointer.

The range of 0 to 64 KB near pointer, 64 to 1024 KB far pointer and 1024 up to 2 GB is huge pointer.

But in new Operating System there is no such types of pointer because today's Operating System is work in Protected Mode. In protected mode there is no such partition of memory.

According to the datatype there is five types of pointer such as
1) Integer Pointer
2) Character Pointer
3) Float Pointer
4) Double Pointer and
5) Void Pointer.

The Integer Pointer is only store the address of Integer variable, we can not store the address of Character variable, float variable and double variable.
To solve this problem we have to generic pointer concept in C language. To achieve this by using void pointer.

The size of pointer is 4 bytes in 32-bit Operating System. But according to the platform we have change the size of pointer.

Syntax of Pointer is :-
         [access specifier][type specifier][return value] *VariableName;
The return value and variable name must be required.

Example : -
                 #include<stdio.h>
                 int main()
                 {
                        int iNum = 10;
                        int *pNum = &iNum;
                        printf("%d  %d", iNum, *pNum);
                        return 0;
                  }

Ouput : 10 10

------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

SYBSc (CS) Sem III : Data Structure Slip 14 Que - 2

  SAVITIBAI PHULE UNIVERSITY OF PUNE S. Y. B.Sc. (Computer Science) Semester III Practical Examination       SUBJECT: CS-233 Practical cours...