C language Handout pointer importance, some people say that learning C language, did not learn the pointer is equivalent to not learning C language, and I am unfortunately, university time is, learned C language, but did not learn the pointer
1 //C language functions to be declared after use we want to unify2#include <stuio.h>3 //function Declaration4 voidtest ();5 intMain ()6 {7 test (); 8 return 1; 9 }Ten One voidTest () A { -printf'Hello world!\n'); -}
Computer, the minimum memory unit is byte, each byte of memory has a unique number, this number is the memory address, under the 32-bit system is a 32-bit integer, under the 64-bit system, is a 64-digit integer
int Main () {int a=0; int *p=&a; // this is wrong. // The address is an integer, but the address is a special integer that cannot be manipulated directly through the certificate . int *p1; // define a variable, named P1, that can point to an int's address
Right, like this.
int x=1;
int *p;
P=x;
printf (*p);//print 1
}
The null pointer and the wild pointer,
In the program to avoid the existence of the wild pointer, because the wild pointer will cause the program to collapse, allowing the existence of NULL pointers in the program
The wild pointer is a pointer to no address
A null pointer is a pointer to a null address
int main () { int a=1 ; int b=2 ; int c=3 ; int *p;p =* A; *p=10 ;p =& B; *p=20 ;p =& C; *p=30 ;p rintf ( " a=%d,b=%d,c=%d ", a,b,c);
}
C language can directly manipulate memory, white is the pointer directly operating memory, which is quite invincible thing!
Pointer constants and pointers to constants---
Constant pointers cannot be randomly fingered
Found good egg pain ah, the knowledge of the pointer should review the review!
Melted down-c/C + + knowledge-all-Stack Road