Results 1 to 7 of 7

Thread: Advantages of using pointers in C

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Answers
    2

    Advantages of using pointers in C

    pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved

    pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values


  2. #2
    Junior Member
    Join Date
    Dec 2007
    Answers
    2

    Re: Advantages of using pointers in C

    pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved

    pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values


  3. #3
    Contributing Member
    Join Date
    Dec 2007
    Answers
    46

    Re: Advantages of using pointers in C

    Quote Originally Posted by dollysinha View Post
    pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved

    pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values
    This was an interesting question. This reminded me to keep in touch with the basics: easy to forget them.

    Okay. Here are the advantages of pointers as I see it.
    - Pointers allow you to implement sharing without copying i.e. pass by reference v/s pass by copying. This allows a tremendous advantage when you are passing around big arrays as arguments to functions.
    - Pointers allow modifications by a function that is not the creator of the memory i.e. function A can allocate the memory and function C can modify it, without using globals, which is a no-no for safe programming.
    - Pointers allow us to use dynamic memory allocation.
    - Pointers obviously give us the ability to implement complex data structures like linked lists, trees, etc
    - Pointers allow ease of programming, especially when dealing with strings. This is due to the fact that a pointer increment will move by the size of the pointee i.e. easy coding to increment to the next memory location of an array, without worrying about how many bytes to move for each data type. I.e. a pointer to a char will move the pointer by a byte, pointer to an int, by the size of the int, etc NOTE that this is important because you do not have to worry about the size of the data types which can vary on different architectures.
    - Pointers allow us to resize the data structure whenever needed. For example, if you have an array of size 10, it cannot be resized. But, an array created out of malloc and assigned to a pointer can be resized easily by creating a new memory area through malloc and copying the old contents over. This ability is very important in implementing sparse data structures also.

    Well, that is all I can think of.


  4. #4
    Junior Member
    Join Date
    Sep 2008
    Answers
    2

    Re: Advantages of using pointers in C

    how many typs of pointers


  5. #5
    Expert Member
    Join Date
    Apr 2008
    Answers
    1,859

    Re: Advantages of using pointers in C

    hi friend..

    The topic is vast, you just refer this link to get a clear idea Pointer (computing) - Wikipedia, the free encyclopedia

    Thanks
    Deepasree


  6. #6
    Expert Member
    Join Date
    Jun 2007
    Answers
    260

    Re: Advantages of using pointers in C

    hi,

    hope this link will help you out Pointers

    Thanks
    Sushma


  7. #7
    Junior Member
    Join Date
    Aug 2008
    Answers
    1

    Re: Advantages of using pointers in C

    Pointer is nothing but a variable which stores the address of another variable.while using the pointer we can store any data type suppose using an array we can able to store particular defined data type only but in pointers we can store any datatype.Its like a reference variable.


  8.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact