A double pointer in C or C++ ...
int ** ppi;
... simply means that ppi is a pointer that points to a pointer that points to an int.
When defining function-parameters, another way of declaring this is ...
int * ppi[];
... which means that ppi is a pointer to an array of pointers that each point to an int, which happens to have the exact same meaning, but it is more telling in terms of what the usefulness of such a double pointer might have.
Think of main() ...
int main (int agrc, char ** argv);
int main (int argc, char * argv[]);
... the two forms have exactly the same meaning, but the second form more clearly says what the design paradigm is, that argv is a pointer to an array of pointers that each point to an array of char, i.e. the arguments of the program's invocation.
It has to do with the memory model you are using... If you are using the LARGE or HUGE memory model, then you use HUGE memory pointers. == Huge pointers are like far pointers, just more so: they are always normalized (ie offset part is between 0 and 15), and segment wrapping-around do not occur if you use them.
A pointer is a primitive variable that can be used to store a memory address. We say the variable "points to" the stored address, hence we call them pointers. The primary operator of a pointer is the dereference operator (prefix *) which allows us to access the value stored at the address being pointed at. Being a variable, pointers also have an address of their own, thus we can use a pointer to point at another pointer.
Like all variables, pointers must be declared with a type although we can use void* if the type cannot be established at compile time. When dereferencing a void* pointer, we must cast the pointer to the appropriate type.
Unlike a named variable which always refers to the same memory address, a pointer can refer to any memory address and we can change that address at any time unless the pointer is declared a constant pointer (in which case it must be initialised at the point of declaration). We can also change the value being pointed at unless the pointer is declared a pointer to constant. Thus for any given type, we have four possible pointer declarations:
Before we can use a pointer we must first assign an address to it and thus initialise it. If we have no suitable address to initialise the pointer, we must assign the all-zeroes bit pattern. On most implementations, the NULL macro is defined to match the all-zeroes bit pattern of the system, which is typically 32 bits in length on a 32-bit system and 64 bits on a 64-bit system.
As soon as the memory being pointed at falls from scope, we must assign NULL to the pointer. This ensures that we don't accidently attempt to dereference memory that is no longer valid (may have been overwritten) or has been released back to the system (no longer belongs to our program). Dereferencing a NULL pointer results in undefined behaviour.
Pointers are primarily used to allow the call by reference semantic. Unlike C++, C has no built-in reference type thus all arguments are passed to functions by value. However, by passing a pointer (by value) we are effectively passing by reference because the value of a pointer is a memory address.
Pointers also have an important role to play with regards arrays, especially variable-length arrays allocated dynamically on the heap (the free store). Whenever we allocate an array, we are setting aside a chunk of memory for one or more elements of a given type. If the array is allocated in static memory or on the stack (local memory), we can name the array just as we can an ordinary variable because the length of the array is known at compile time (fixed-length arrays). Thus the array name refers to the start address of the allocation. But if the array is allocated on the heap, we must use a pointer variable to store the start address. Regardless, the elements of an array are anonymous (we cannot refer to elements by name) with the exception of named arrays where the first element (only) can be referred to by the array name.
Although they have no names of their own, every array element has identity (a memory address). Given that each element is of the same type and therefore the same length, it is trivial to calculate the address of each element by its zero-based index from the start of the array. Trivial as it is, the array suffix operator allows us to access elements without resorting to pointer arithmetic (the compiler generates the pointer arithmetic for us Behind the Scenes).
Arrays implicitly convert to pointers at the slightest provocation. This makes it impossible to pass arrays by value because once converted to a pointer, the length of the array is lost. Thus arrays are always passed by reference and the length of the array (its dimension) is passed via a separate argument.
A pointer is a variable that can store a reference (a memory address) or can store a NULL value (zero). The only use of any pointer in C++ is whenever you need to refer to memory that, for whatever reason, may not be valid. That is, if there is any possibility that a reference could be NULL, then you must use a pointer, because NULL references are invalid in both C and C++.
By way of an example, when you dynamically instantiate a new object at runtime, there is no way to guarantee that a sufficient block of free memory will be available, therefore you cannot reference that memory. For that reason, the new operator returns a pointer, not a reference. This is no different to the way the malloc() function returns a pointer, not a reference, in C.
As well as dynamic allocations, pointers can also be used to pass objects to functions. While programmers are encouraged to pass objects by reference rather than by value, it is sometimes desirable to pass a NULL reference. But since references can never be NULL, a NULL pointer must be passed instead.
Since pointers are variables they are more flexible than references insofar as once a memory address is assigned to a reference, that reference cannot refer to any other memory address while it remains in scope. But pointers can be assigned to point at any reference, including a NULL reference, at any time.
We can use pointers in user defined functions, the reason behind is we can access the actual parameters indirectly by using pointers. And also we can reduce the length of a complicated program into very small code. It is easy to manipulate with pointers.
sizeof (void *)
often 2, 4 or 8 bytes
sizeof (void *) often 2, 4 or 8 bytes
Accessing data by address.
Four bytes.
void pointer
insert or delete values both side.so use double pointer
Increment or decrement the pointer by the required offset.
When a variable is declared as being a pointer to type void it is known as a generic pointer. Since you cannot have a variable of type void, the pointer will not point to any data and therefore cannot be dereferenced. It is still a pointer though, to use it you just have to cast it to another kind of pointer first. Hence the term Generic pointer.
The pointer that points to a block of memory that does not exist is called a dazzling pointer or wild pointer
void pointer
is C or D
C
Pointer in C is Memory Reference. It stores memory address of any variable, constant, function or something you later use in your programming. Pointer basically used to ease the referencing of variables and others or in polymorphism and inheritance.
insert or delete values both side.so use double pointer
pointer: to access data by address reference: there is no reference in C language
Pointer is a variable that stores address of a variable . A NULL Pointer a pointer that doesn't point to anything, it is a literal zero .Some people ,notably C++ programmers, prefer to use 0 rather than NULL.
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.
A pointer looks a bit like a stick. I use it to point at something. Read your text book, read C tutorials on the web and if you still cannot answer the question consider floor sweeping or basket weaving as a vocation.
It is a pointer that points to a member of a structure.
Increment or decrement the pointer by the required offset.
no