# Include
# Include
/*
Conclusion: No matter how hard he is
*/
Void getData01 (char * p1)
// Char * p is the parameter of the function called by the row Parameter Element of the parameter, but it only has external attributes.
{
Printf ("getData01 () begin \ n ");
Return;
}
Void getdata02 (char ** p2) // char ** p2 row parameter p2 is a variable
{
Printf ("getData01 () begin \ n ");
Return;
}
Void getdata03 (char ********* p7) ******** the p7 row parameter p2 is a variable
{
Printf ("getData01 () begin \ n ");
Return;
}
Void main ()
{
Int * p1 = null;
Int ** p2 = null;
Int a = 10;
Int * p3 = null;
Int c = 0;
A = 20; // modify the value of a directly through the variable
P3 = & a; // assign the address of a to p3
P3 = 30; // indirectly modify the value of p3
C = * p3;
// Assign the value in p3 to c. Note that it is not an address. Explain * the address of a in p3, a = 20, and assign 20 to c;
Conclusion: * p indicates that * It is like a key. Based on the value of a pointer, modify the memory space.
For example
/*
While (* p! = '\ 0 ')
{
* P ++ = * p2 ++;
It is interpreted that p2 ++ is a value, and the obtained value is assigned to * p ++.
}
*/
}
// Exercise
Void main ()
{
Char * p1 = null;
// Define a char type pointer variable p1 and assign the value of p1 to null;
Char * p2 = null;
// Define a char type pointer variable p2 and assign the value of p2 to null;
Char buf1 [100] = {0 };
// Define an array of the char type as buff1, where the number of buf1 elements is 100
Char buf2 [100] = {0 };
// Define a char type array as buff2, where the number of buf2 elements is 100
Strcpy (buf, "abcdefg ")
P1 = buf1;
// Assign the first address of buf1 to p1
P2 = buf2;
// Assign the first address of buf2 to p2
While (* p1! = '\ 0 ')
{
* P2 = * p1;
// * Assign values to the left
// * Put the value on the right side to get the value inside.
P2 ++; // move one byte backward. If it is int type, it will move four bytes.
P1 ++;
}
}
Key Points
How do you understand the following pointer?
1. How should we understand the pointer type of the parameter?
A) Understanding must begin from two perspectives.
I. represents the type parameter in the c/c ++ compiler. If it is a pointer type, the c compiler will allocate only four bytes.
Ii. Char * p parameter p is a variable
2. What is the pointer data type?
A) the pointer data type is the value of the data type in the memory space it refers.
I. The data type of the pointer has the attachment feature.
Conclusion: The length of the pointer is determined based on the memory space type.
Void senddata01 (char * p1); void senddata01 (char * p1 );
Void senddata02 (char ** p1); void senddata02 (char ** p1); void senddata02 (char ** p1 );
Void senddata03 (char *** p1 );
Void senddata04 (char * p []); void senddata04 (char * p []); void senddata04 (char * p []);
Void senddata05 (char (* p) [10]); void senddata05 (char (* p) [10]);
Void senddata05 (char ***** p4 );