The improtance of replacing values in pointers

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2004
Posts: 13
Reputation: smarkles is an unknown quantity at this point 
Solved Threads: 0
smarkles smarkles is offline Offline
Newbie Poster

The improtance of replacing values in pointers

 
0
  #1
Sep 16th, 2004
Our instructor asked us why its important to be able to replace values in a pointer........Here is what I came up with...

By using a pointer, a block of memory is allocated at runtime, therefore a program can be more flexible than one that allocates all its memory at once(read from a book). Also, a pointer is easy to store rather than a large struct or a class object.A pointer just stores an address that can be easily passed to a function whereas if an object is passed to a function it had to be constructed, copied and destroyed.......making total sense of a pointer. But its giving examples of this that I'm having a mentall block with. Any help will be appreciated thanks, I think that this will totally clear me up on pointers.Smarkles.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 185
Reputation: Stack Overflow is an unknown quantity at this point 
Solved Threads: 4
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline Offline
C Programmer

Re: The improtance of replacing values in pointers

 
0
  #2
Sep 17th, 2004
I think your answers foreground is good.

Changing values in pointers are good also because, as you said, it stores a block of memory that can be passed to any variable at any given time.

A pointer is a variable that contains the address of another variable. Pointers and arrays are closely related, are sometimes the only way to express a computation, and usually lead to more compact and efficient code.

Pointer handling means greater if we understand that they contain and pass memory address blocks easily, allowing the change of such a variable simple. They can be passed through functions, and be altered there. The complexity of it all makes it all to simple. Pointers co-exist with their main source. The change of one affects the other(s).

In the simplest terms, pointers resemble mirror-like.

I hope this sounds understandable.


- Stack Overflow
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.

IRC
Channel: irc.daniweb.com
Room: #c, #shell
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2037 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC