Const
The compiler typically does not allocate memory for normal const, but instead saves them in the symbol table.
This makes it a constant during compilation, with no storage and read operations, making it highly efficient
const INT * Const P4 = &a;
const INT * P4 = &a;
int * Const P4 = &a;
Memory skills look at the position of *
If the const on the left side of the * indicates that the value cannot be changed, but pointing can change
If const on the right side of the * indicates that the point cannot be changed, but the value can be changed
If on * But both sides there is a const identity point and the value cannot be changed
5) malloc function:
int main (int argc, const char * argv[]) {
The first address of the newly requested memory space is stored in P
If you do not assign a value to a malloc application, the amount of garbage stored is
int *p = (int *) malloc (4 * sizeof (int));//16 bytes
Calloc: Allocating memory space for the specified number of blocks and lengths
Format: calloc (number of blocks, length)
Allocated 4 pieces of memory with 4 bytes each
Their addresses are also contiguous and can be automatically initialized to 0.
int *P1 = (int *) calloc (4, sizeof (int));
Relloc can extend the size of existing memory space
return new memory space address
p = realloc (p, + * sizeof (int));
Using a function to initialize the memset, the intermediate is the ASIC code;
memset (P, ' A ', 16);
if (P! = NULL) {
*p = 10;
* (p + 1) = 100;
* (p + 2) = 1000;
}else{
printf ("Failed to request memory space!") ");
}
printf ("%p%p%p", *p, * (P + 1), * (P + 2));
return 0;
}
C Language Doubt Point