| | |
The improtance of replacing values in pointers
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2004
Posts: 13
Reputation:
Solved Threads: 0
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.
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.
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
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
IRC
Channel: irc.daniweb.com
Room: #c, #shell
![]() |
Similar Threads
- pointers to chars (C++)
- Pointers, Arrays and Creating Objs... (C++)
- Program Crashing PT2 (C++)
- Linked Lists and Copy Constructor (C++)
- how to print null subtree of a null subtree? (C++)
- map / multimap memory requirements (Computer Science)
- plz help me to do this(new) (C++)
Other Threads in the C Forum
- Previous Thread: Using sound card in C?
- Next Thread: file pointer increament
Views: 2037 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C
#include .net ansi array arrays asterisks binarysearch calculate centimeter changingto char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics hacking hardware histogram homework inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard mysql number opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures student systemcall testing threads turboc unix user variable voidmain() wab windowsapi





