A pointer is a memory variable that contains the address of another memory variable. They were widely used in older, procedural programming languages like C. Using pointers allowed programmers to write very fast, low-level code. But pointers also exposed some security risks that were difficult to identify when the programs were being written. Pointer use is allowed in C#,
-----------------
There could be many situations in which you may need to use a pointer.
Comes to mind the need to build a list of objects that needs to be able to grow without other limits than the available resources on the system.
This can be done with a linked list, using pointers.
If you use an array, you need to pre-define a maximum number of elements, and on the other hand, your program will always use the amount of memory needed to store all the elments of the array, whether it is full or not.
As mentioned by Mr.Carlosdl, pointer is required whenever the program needs to use heap memory access using dynamic memory allocation (alloc/malloc/calloc/new). In addition to allocation of dynamic memory, pointer can also be used to access file descriptors.
Last Wiki Answer Submitted: January 30, 2010 6:12 am by carlosdl63,535 pts.
All Answer Wiki Contributors: carlosdl63,535 pts. ,
Mukul4645 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.