Pointers are addresses to locations in memory which store data.
Under normal circumstances, memory for variables is already allocated when the program runs. The size of the memory cannot be changed, which is insufficient for some applications.
Hence, memory allocation, reallocation and deallocation functions exist to allow the programmer more freedom in using memory.
Blocks of memory allocated by the program can be easily resized or reallocated for other purposes. For instance, an array declared as follows:
int myarray[20];
has, and will always have, 20 values - it cannot resize, and is known as a static array. However, if you want to be able to resize this array, it's best to redeclare it as an intpointer:
int *myarray=NULL;
Thus, realloc() is the only function necessary for manipulating it:
myarray=(int*)realloc(myarray, sizeof(int)*newarraysize);
Set the new value for newarraysize, and make the above call to resize the array. Then, when you're done with myarray, free(myarray). This is called a dynamic array, since it can be resized dynamically.
Another use of pointers is in linked lists, which are valuable when inserting or removing items to or from arbitrary locations in a list is desired. Allocate the memory for a new node, adjust the variables pointing to the old node to the new node, and free the memory for the old node. Linked lists are faster than arrays in this case, particularly when dealing with large amounts of data.
The pointer indicates the location of variable . and also *p is indicates the value of the corresponding pointer address....... this is basic advantage of pointers...
C and C++ will help you understand the inner workings of a computer with operations such as dealing with memory and pointers. It will do anything that you tell it to do, which is both an advantage and a disadvantage.
The first and the third answer.
Java doesn't have pointers. C++ has pointers.
C does not have stream pointers.
pointers.
Nothing.
Yes, you can use pointers in the C#, but to some extent. Links are added with more details.
addresses
Accessing data via pointers.
Pointers in C are stored as integers. You can perform any mathematical operations on pointers that you can perform on ints.Of course not, the following operations are possible: =, +, +=, ++, -, -=, --, *, [], ->, typecast
Pointers in C are generally the thing that gives learners the most trouble. When C code is not written correctly with respect to pointer use, the resulting bugs can often be very difficult to find and correct. On the other hand, pointers are absolutely necessary in some cases.The designers of Java wanted to make programming easier and hence avoided adding pointers to the language. Java does have object references which accomplish much of what pointers accomplish albeit in a safer way.
You can either use references or you can simply return the result by value. Note that in C++, unlike C, references are not the same as pointers. C++ references are aliases, alternate names for existing objects, whereas pointers are just variables that may contain a memory address that can be dereferenced.