Turn from: Jimmy
the pointer has two properties: point to the address and length of the variable/object
But the pointer only stores the address, and the length depends on the pointer's type the
compiler addresses the from the pointer's address according to the type of the pointer,
the pointer type is different and the addressing range is different, such as:
int* Searches backwards from the specified address for a storage unit of 4 bytes as a variable
double* searches backwards from the specified address for a storage unit of 8 bytes as a variable
1.void Pointer is a special pointer
void *vp
/say it especially because it has no type
//or this type cannot determine the length of the pointer to the object
2. Any pointer can be assigned to a void pointer
type *p;
vp=p;
//No conversion
//Obtain only the variable/object address without getting the size the
3.void pointer is assigned to other types of pointers and is converted
type *p= (type*) VP;
//The type of conversion is to obtain a pointer to the variable/object size
Ext: http://icoding.spaces.live.com/blog/cns!209684E38D520BA6 !130.entry
4.void Pointer cannot re-reference
*vp//error
because void pointer only knows, point to variable/ The start address of the object is
does not know the size of the pointer to the variable/object (a few bytes), so cannot be referenced correctly;
5.void Pointer cannot participate in pointer operations unless the conversion is
(type*) vp++;
//vp==vp+sizeof (type)
The difference between void * and void in the return value of a function
A problem that is easily confused.
In the return value of a function, void is no return value, and void * is a pointer to a value of any type.
Let's look at the code:
#include <stdlib.h>
#include <stdio.h>
void voidc (int a);
void* VOIDCP (int *a);
int main () {
int a=10;
int *ap;
VOIDC (a);
AP = VOIDCP (&a);
printf ("%d\n", *ap);
return 0;
}
void voidc (int a) {
printf ("%d\n", a);
Return No return value
}
void* VOIDCP (int *a) {
printf ("%d\n", *a);
return A; return int *
}
The result is:
10
10
10
Reprint--void pointer (void * usage)