About Me

Hey friends! My name is yuvraj basnet. I'm going to introduce myself.I have born and grown up in india(chandigarh) and I'm studying second year of B.C.A computer science field. My father serving in indian air force. My mother has been taking care of house hold. I am a friendly person, good thinker, I can work for longer hours without any break, only if I'm interested in that...My life style is very simple.

POINTERS IN C


In this tutorial you will learn important topic Pointer in which i cover all important terms of pointers, syntax of pointer, example of pointer etc. 

further wasting anytime lets get started

POINTER 
A pointer is a variable that store the address of another variable. A pointer in a C
is used to allocate dynamic memory i.e, run time. The pointer variable belonging to any of the datatype such as int, float, char and short etc. 
so, it become necessary to learn pointer to become a perfect programmer.

DECLARATION OF POINTER VARIABLE SYNTAX
DATA_TYPE *VARIABLE_NAME;

EXAMPLE
int *point;

Here, Where, * is used to denote that “point” is pointer variable and not a normal variable.


    KEY POINTS TO REMEMBER ABOUT POINTERS IN C:

  • & symbol is used to get the address of the variable.
  • Always C pointer is initialized to null, i.e. int *p = null.
  • Normal variable stores the value whereas pointer variable stores the address of the variable.
  • If a pointer in C is assigned to NULL, it means it is pointing to nothing.
  • * symbol is used to get the value of the variable that the pointer is pointing to.
  • But, Pointer addition, multiplication, division are not allowed.
   PROGRAM TO IMPLEMENT POINTER


    OUTPUT

  OPERATORS THAT ARE USED WITH POINTER:
 1)“Address of”(&) Operator - The address of any variable is given by preceding the          variable name with Ampersand &.

 2) * (Value at) - To access the value of a certain address stored by a pointer variable, * is        used. Here, the * can be read as 'value at'.

      FEATURES OF POINTER:
  • Amazing feature of pointers: Pointers provide direct memory access.
  • By using pointers we get multiple values from the function, as we know a function can return only one value but by passing arguments as pointers we can get more than one values from the pointer.
  • By using pointers we can design and develop complex data structures linked list etc.
  • By using pointers dynamic memory can be created according to the program use. We can save memory from static (compile time) declarations.
   DISADVANTAGES OF POINTER
   Since pointers has many features but there are some disadvantages of pointers
  • Failed to protect memory addresses (locations) - Since pointer can access direct memory so memory cannot be protected.
  • Uninitialized pointers can cause of segmentation fault.
  • Pointers variables are slower than normal variables.
  MORE ABOUT POINTERS:
1)POINTER- TO- POINTER:
    when one pointer variable contain the address of another pointer variable, it is            known as Pointer to Pointer variable.


   OUTPUT

2)Pointer to Array


   OUTPUT









   

Post a Comment

0 Comments