This blog is under construction

Saturday, 5 October 2013

Advantages and disadvantages of pointers in c

Benefits(use) of pointers in c:

  • Pointers provide direct access to memory
  • Pointers provide a way to return more than one value to the functions
  • Reduces the storage space and complexity of the program
  • Reduces the execution time of the program
  • Provides an alternate way to access array elements
  • Pointers can be used to pass information back and forth between the calling function and called function.
  • Pointers allows us to perform dynamic memory allocation and deallocation.
  • Pointers helps us to build complex data structures like linked list, stack, queues, trees, graphs etc.
  • Pointers allows us to resize the dynamically allocated memory block.
  • Addresses of objects can be extracted using pointers

Drawbacks of pointers in c:
  • Uninitialized pointers might cause segmentation fault.
  • Dynamically allocated block needs to be freed explicitly.  Otherwise, it would lead to memory leak.
  • Pointers are slower than normal variables.
  • If pointers are updated with incorrect values, it might lead to memory corruption.
Basically, pointer bugs are difficult to debug.  Its programmers responsibility to use pointers effectively and correctly.

61 comments:

  1. This content is very much helpful for me.. Thank you :)

    ReplyDelete
  2. I have a doubt. As mentioned in the dis-adv if the Pointer are slower than the normal variables then how can they reduce the execution time ?

    Pardon me if the doubt is lame. I am new to C Language.

    ReplyDelete
  3. Really an great help.....
    & i like your blogspot name "see programming" :)

    ReplyDelete
  4. Yes, I have the same view with "Unknown".Could you explain to us, how pointer can reduce the execution time. Im new also in programming c

    ReplyDelete
  5. Yes, I have the same view with "Unknown".Could you explain to us, how pointer can reduce the execution time. Im new also in programming c

    ReplyDelete
  6. I have the same doubt regarding to execution time reduction because of pointer.

    ReplyDelete
    Replies
    1. Hey
      Because pointer hits the location or address of a variable so execution speed is fast.
      And maybe pointer takes address slowly in compare of normal variable takes value so pointer is slower than normal variable

      Delete
    2. Hey
      Because pointer hits the location or address of a variable so execution speed is fast.
      And maybe pointer takes address slowly in compare of normal variable takes value so pointer is slower than normal variable

      Delete
  7. how can i insert unlimited records in programms of c++ using pointer and array

    ReplyDelete
  8. Even I have the same doubt as unknow have.........

    ReplyDelete
  9. because it's a indirect access to the variable so it's slower then normal variable

    ReplyDelete
  10. How to implement linklist,tree and graph without Pointer?

    ReplyDelete
  11. Thank you much.this is very helpful.

    ReplyDelete
  12. Thank you much.this is very helpful.

    ReplyDelete
  13. Main drawback of pointer is it doesn't provides security. That's y pointers are committed in oops

    ReplyDelete
  14. Main drawback of pointer is it doesn't provides security. That's y pointers are committed in oops

    ReplyDelete
  15. Replies
    1. hii archana do u any certificates of online course

      Delete
  16. let us assume the chess board as memory,give the numbers from 0 to 63 in boxes of board.assume each box as 1 byte,now you declare the int pointer variable it will take 4 bytes,it occupies the address from 0 th box to 3 rd box,so the address of the integer variable is 0-3.similarly for every variable we have a particular address.this will provide to access memory easily and through address we can easily find the location reach destination fastly, similarly here also execution will take less time,just image these things in real world you will get an idea.

    ReplyDelete
  17. Thanks admin can u share your email id with me

    ReplyDelete
  18. Nice tutorial. Thanks for sharing the valuable info about c Training. it’s really helpful. Who want to learn c language this blog most helpful. Keep sharing on updated tutorials…..

    ReplyDelete
  19. Really, these quotes are the holistic approach toward mindfulness. In fact, all of your posts are. Proudly saying I’m getting fruitfulness out of what you write and share. Thank you so much..
    Devops Training in Bangalore
    R Programming Training in Bangalore

    ReplyDelete
  20. @ Very nice blog. You can also find C, C++, Java programming tutorial at BestBCANotes.com

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. what is the difference b/w pointer as function argument & pointer to function?

    ReplyDelete
  23. You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.
    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  24. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Python Training in Bangalore

    ReplyDelete
  25. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. Best AWS Training in Bangalore

    ReplyDelete
  26. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    AWS Training in Bangalore
    Python Training in Bangalore

    ReplyDelete
  27. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.

    amazon web services training in bangalore


    ReplyDelete
  28. Nice post.Thank you so much for sharing.Yiioverflow is a web development company.We have well expert team in Angular JS, Ionic, Yii Framework, Node JS, Laravel, PHP, MySQL, and WordPress.If you want a developer visit.. https://yiioverflow.com/

    ReplyDelete
  29. Yiioverflow presenting one of the best and high performance PHP framework. Fast, secure and extremely professionals are developing applications. We guide to implement mobile app development and SOA hybrid applications.Code in Nodejs, Angular,Ionic,ReactJS and Yiiframework.

    ReplyDelete
  30. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    Digital Marketing Training in Bangalore

    ReplyDelete
  31. Thak you very much.very useful for everyone

    ReplyDelete

  32. To improve Knowledge about the latest and vital technology would increase one's self esteem to the core at the time of lagging confidence.The content presented here is quite resembling the same. You have done a great job by sharing this in here. sap abap crm training

    ReplyDelete