C/C ++ the full stack of Knowledge furnace (c), the road to knowledge Furnace
The importance of C-language handout pointers. Some people say that learning C language is equivalent to not learning C language. Unfortunately, in college, I learned C language but didn't learn pointers.
1 // in C language, the function must be declared first and then used. We need to unify 2 # include <stuio. h> 3 // function declaration 4 void test (); 5 int main () 6 {7 test (); 8 return 1; 9} 10 11 void test () 12 {13 printf ('Hello world! \ N'); 14}
The minimum unit of memory for a computer is byte. Each byte memory has a unique ID, which is the memory address. It is a 32-bit integer in a 32-bit system, in a 64-bit system, it is a 64-digit integer.
Int main () {int a = 0; int * p = & a; // This is incorrect // The address is an integer, but the address is a special integer, is an int * p1 that cannot be operated directly through the certificate; // defines a variable named p1, which can point to an int address.
// Correct like this
Int x = 1;
Int * p;
P = x;
Printf (* p); // print 1
}
NULL pointer and wild pointer,
Avoid the existence of the wild pointer in the program, because the wild pointer will cause the program to crash and allow the existence of the NULL pointer in the program
The wild pointer does not point to the 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;printf("a=%d,b=%d,c=%d",a,b,c);
}
The C language can directly operate the memory. To put it bluntly, the pointer directly operates the memory, which is rather invincible!
Pointer constant and pointer to constant ---
Constant pointers cannot be out of the box
I found it quite painful. I should review the pointer knowledge!