Four pointers and arrays
< a > pointer is the address
1 define int *p;
2 Initializing int a,*p=&a;
Give the address of a to *p.
The pointer variable has whose address is pointing to WHO. The *p represents this variable. *P represents a
3 operation
int a,*p=&a;
*p=5; <-----assigned a 5 to a
int *p,a;
*p=[*&]a;
| Offset the
*p <=>a Equivalence
NOTE: * Three uses 1 multiplication operation 2 operator 3 specifier
Define time to use such as int a,*p=&a;
A two-array character array also requires
1 Defining one-dimensional two-dimensional both will be
2 Initialize one-dimensional two-dimensional to be back
3 element Reference
Citation----> Subscript method A[i]
-----> Pointer method: Precondition: Pointer pointing first to re-reference (int a[10],*p=a;)
P+i or a+i represents the address of the element I
* (P+i) or * (a+i) First element
4 element Assignment
Initialization
Input from keyboard
enter int a[10],*p=a; Output int ....
for (i=0;i<=j;i++) for ...
scanf ("%d", &a[i]); printf ("%d", * (P+i));
P+i or * (a+i)
C++
5 String function Copy connection you're going to make it.
The key points and difficulties in five-function test centers
1 functions first type function name parameter
{
function body
}
2 Return of function and type of function
Encounters | return expression; Expression type is the function type <---has a return value
return | Return void type
| }
For example
Main () {
int s;
Xxxx
s = Fun (s); <----has a return value
Xxxx
}
int fun (int x) {
Xxxx
return expression;
}
Main () {void fun (int x) {...}
int s;
Fun (s); <-----no return value
}
Main () {void fun (int x) {...}
int s;
printf ("%f", Fun (s));
return value and the function value is float
}
Main () {float fun (int x) {return;}
int s;
printf ("%f", Fun (s));
}----> has a return value and the function value is float
3 function calls
1> principle:1> first defined and then called 2> if it violates the 1 principle, it needs the first part of function description;
4 parameter pass key is tuned
Call-time argument-----value 1-----> Parameter
<-----2--------
return expression
Call End
Four pointers and array five functions