, . , .
void swap(int*,int*);
void main(void){
int x=5, y=10;
printf (" =%d, y=%d\n",x, y);
swap (&x, &y);
printf (" =%d, y=%d\n", x, y);
}
void swap (int*v, int*z){
int u;
u=*v;
*v=*z; //x=y
*z=u;
}
, , . .
swap (x, y); swap (&x, &y);
swap (int v, int z); swap (int*v, int*z);
, y main, , , .
. .
Mas -> &mas[0]; - 1- . . .
void main(void){
int dates [4], *pti, i;
float bills [4], *ptf;
pti=dates;
ptf=bills;
for (i=0; i<4; i++)
printf (" +%d: %10u %10u\n", i, pti+i; ptf+i);
}
+0: 56014 56026 - .
+1: 56016 56030
+2: 56018 56034
+3: 56020 56038
1 , , , .. .
t pt+1 pt+2 pt+3
dates+2 <=> &dates[2]
*(dates+2) <=> dates[2]
*dates+2 <=> *(dates)+2
// .
for(i=0;i<10; i++)
sum+=*(ptm+i);
for(i=0;i<10; i++){
sum+=*ptm;
ptm++;
}
for(i=0;i<10; i++)
sum+=*ptm++;
int mas[2][2], *pti;
pti=mas[0]; //pti=&mas[0][0]
pti+1<=>&mas[0][1]; //
pti+2<=>&mas[1][0]; //
// .
:
mas[0]<=> &mas[0][0];
mas[1] <=>&mas[1][0]; // ,
// 2- .
1.
int*px, x=2; px=&x;
2. - - .
3. .
px=&x; y=*px; //y==x; , y
|
|
*px=10; x=10;
4. *px+2 // , px, 2.
++; // +1 .
++;
4. ==,!=, >=, <=, >, <
//
void main(void) {
char ar1[100], ar2[100];
char *pa1, *pa2;
pa1=&ar1;
pa2=&ar2;
while(pa2<(ar2+sizeof(ar2)))
*pa1 ++=* pa2++;
}
. , .
, . " type" , , .
, . , type, type. type 10 , 5 50 . , . , ptr1 , ptr2 , ptr2 - ptr1 7.
" type" , " type". type , " type" sizeof(type).
, , " " , . P , P+1 , . . .