Arrays takes consecutive memory space.
So, if you have 5 consecutive memory blocks free which is consecutive, an error will
occur while creating an array which takes more than 5 blocks of memory.
But if you use pointer, then it don't need consecutive memory blocks all the elements can be placed anywhere in memory.
.pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values
In computer terminology, pointer is a programming language. It is an important part of C language. Uses of pointers: C pointer, C arrays, C linked list, memory-mapped hardware, Pass-by-address using pointers, Dynamic memory allocation.
Pointers are used for accessing the addresses of varibles and functions which are usedin our program directly.
i have seen the answer from other site and improved
the advantages of pointers as I see it.
- Pointers allow you to implement sharing without copying i.e. pass by reference v/s pass by copying. This allows a tremendous advantage when you are passing around big arrays as arguments to functions.
- Pointers allow modifications by a function that is not the creator of the memory i.e. function A can allocate the memory and function C can modify it, without using globals, which is a no-no for safe programming.
- Pointers allow us to use dynamic memory allocation.
- Pointers obviously give us the ability to implement complex data structures like linked lists, trees, etc
- Pointers allow ease of programming, especially when dealing with strings. This is due to the fact that a pointer increment will move by the size of the pointee i.e. easy coding to increment to the next memory location of an array, without worrying about how many bytes to move for each data type. I.e. a pointer to a char will move the pointer by a byte, pointer to an int, by the size of the int, etc NOTE that this is important because you do not have to worry about the size of the data types which can vary on different architectures.
- Pointers allow us to resize the data structure whenever needed. For example, if you have an array of size 10, it cannot be resized. But, an array created out of malloc and assigned to a pointer can be resized easily by creating a new memory area through malloc and copying the old contents over. This ability is very important in implementing sparse data structures also.
If you don't know, then don't use them. Maybe later.
yea that's why its called the point FINGER
Answergenerally we use simple pointer, void pointer,null pointer, structure pointer. Answerzero or more (unlimited).
In c a pointer is a variable that points to or references a memory location in which data is stored. Each memory cell in the computer has an address that can be used to access that location so a pointer variable points to a memory location we can access and change the contents of this memory location via the pointer. Pointer declaration A pointer is a variable that contains the memory location of another variable. The syntax is as shown below. You start by specifying the type of data stored in the location identified by the pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you give the name of the variable. type * variable name Example: int *ptr; float *string;
Pointer to Pointer is a double pointer, denoted by (**). Pointer stores the address of the variable and pointer to pointer stores the address of a pointer variable and syntax can be given as int **ptr2ptr;
pointer
pointer is the variable that holds the address of another variable
normal variable stores a value of the given datatype where as the pointer variable stores the address of a variable. for example int n=10; int *p; p=&n; here p is a pointer variable and n is a normal variable.p stores the address of n where as n stores an integer value. *p prints the value of n,p prints the address of n.
Pointer is a variable, A variable that stores the address of another variable. Size of a pointer is 2 bytes.
Pointer is a variable that stores the address of another variable. Since pointer is also akind of variable, thus pointer itself will be stored at a different memory location.
Pointer is a variable that stores the address of another variable . So pointer basically stores the address of another variable and size of pointer can be evaluated by using sizeof operator.
with the help of pointers we able to store the memory location of any variable. In c the pointer variable is use to store the memory location of any variable. The pointer variable is define as a simple variable but in pointer variable use a special "*" character at the left most side of name of pointer variable. If any variable name have * it means it is a pointer variable it hold the memory location of variable.
pointer variable B holds base address of B
A pointer is used for pointing to a variable. It contains the address of the variable to which it points
A void pointer variable is a pointer variable (of some type) that is assigned the value zero, meaning it points to address zero. Memory address zero is a reserved address, which means the pointer variable references nothing in particular.
Double (**) is used to denote the double pointer. As we know the pointer stores the address of variable, Double pointer stores the address of any pointer variable. Declaration : int **ptr2Ptr;
yea that's why its called the point FINGER
Answergenerally we use simple pointer, void pointer,null pointer, structure pointer. Answerzero or more (unlimited).