July 11, 2017 18:33:41
The C-pointer should look at address: http://www.runoob.com/cprogramming/c-pointers.html
1. Learning the C language pointer is simple and fun. With pointers, you can simplify the execution of some C programming tasks, and there are tasks such as dynamic memory allocations that cannot be performed without pointers. Therefore, to be a good C programmer, learning pointers is very necessary.
As you know, each variable has a memory location, and each memory location defines an address that can be accessed using the hyphen (&) operator, which represents an address in memory. Take a look at the following example, which will output the defined variable address:
Instance
#include <stdio.h>
int main ()
{
int var1;
Char var2[10];
printf ("Address of the VAR1 variable:%p\n", &var1);
printf ("Address of the VAR2 variable:%p\n", &var2);
return 0;
}
2. What is a pointer?
A pointer is a variable whose value is the address of another variable, that is, the direct address of the memory location. Just like any other variable or constant, you must declare it before using the pointer to store other variable addresses. The general form of a pointer variable declaration is:
Type *var-name;
Here, type is the base type of the pointer, it must be a valid C data type, and Var-name is the name of the pointer variable. The asterisk * used to declare the pointer is the same as the asterisk used in the multiplication. However, in this statement, the asterisk is used to specify that a variable is a pointer. The following is a valid pointer declaration:
int *ip; /* A pointer to an integral type */
Double *DP; /* A double type of pointer */
float *FP; /* A floating-point pointer */
Char *ch; /* A pointer to a character type */
The actual data type of the value of all pointers, whether integer, float, character, or other data type, is the same as a long hexadecimal number representing the memory address. The only difference between pointers to different data types is that the data type of the variable or constant that the pointer points to is different.
3.
C Basic knowledge "pointers"