Xx_Introduction
ポイントとアレイゲルマン。
Xx_Code
#include<stdio.h>
#define SIZE 4
int main(void)
{
short arra[SIZE];
short * a;
double arrb[SIZE];
int i;
double * b;
a = arra;
b = arrb;
for (i = 0; i < SIZE; i++)
printf("%d %p %p \n",i ,a + i,b + i);
return 0;
}
Ax_Addressと価値
dates + 2 == &dates[2]; //true address
*(dates + 2) == dates[2]; //true value
*dates + 2 = (*dates) + 2; // Beause '*' > '+'
<<<<<<<<<< >>>>>>>>>>>>「私は、分割線です」
Bx_Replace
XAは、ポインタを使用しません
#include<stdio.h>
#define M 12
int main(void)
{
int days[M] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int i;
for (i = 0; i < M; i++)
printf("Month %2d has %2d days.\n", i + 1, days[i]);
return 0;
}
XB使用ポインタ
#include<stdio.h>
#define M 12
int main(void)
{
int days[M] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int i;
for (i = 0; i < M; i++)
printf("Month %2d has %2d days.\n", i + 1, *(days + i)); // equal to days[i]
return 0;
}
XCお知らせ
VV(逆も同様)ポインタを表すために使用するアレイが、注目に
配列は、引数の関数であるとき。