1.数组类型
C语言中的数组有自己特定的类型
数组类型由元素类型和数组大小共同决定,EG: int array[5] 的类型为 int[5]
2.定义数组类型
C语言中通过 typedef 为数组类型重命名 EG: typedef type(name)[size]
数组类型定义
typedef int(AINT5)[5];
AINT5 iArray;
#include <stdio.h>
typedef int(AINT5)[5];
typedef float(AFLOAT10)[10];
typedef char(ACHAR9)[9];
int main()
{
AINT5 a1;
float fArray[10];
AFLOAT10* pf = &fArray;
ACHAR9 cArray;
char(*pc)[9] = &cArray;
char(*pcw)[4] = &cArray;
int i = 0;
printf("%d, %d\n", sizeof(AINT5), sizeof(a1));
for(i=0; i<10; i++)
{
(*pf)[i] = i;
}
for(i=0; i<10; i++)
{
printf("%f\n", fArray[i]);
}
printf("%p, %p, %p\n", &cArray, pc+1, pcw+1);
return 0;
}
3.指针数组
指针数组是一个普通的数组
指针数组中每个元素为一个指针
指针数组的定义: type* pArray[n]