Void of C language learning notes
? 1. void literally means "no type", void * means "no type Pointer", and void * can point to any type of data.
? 2. Usage 1: Data Type Encapsulation
Int InitHardEnv (void ** handle );
Typical function prototypes for memory operation functions such as memcpy and memset are
Void * memcpy (void * dest, const void * src, size_t len );
Void * memset (void * buffer, int c, size_t num );
? 3. Usage 2: Modify the return value and parameters of the void function, which only indicates none.
If the function does not return a value, declare it as void.
If the function has no parameters, you should declare the parameter as void.
Int function (void)
{Return 1 ;}
? 4. Significance of the void pointer
C language requires that only pointers of the same type can be assigned values to each other
Void * the pointer is used as the left value to receive any type of pointer.
Void * forced type conversion is required when the pointer is assigned to another pointer as the right value
Int * p1 = NULL;
Char * p2 = (char *) malloc (sizoeof (char) * 20 );
? 5. The void type variable does not exist.
The C language does not define the alias for how much memory the void is.