数组指针的定义方式
- 通过typedef先定义出数组类型,再通过数组类型定义数组指针
- 通过typedef先定义出数组指针类型,再通过数组指针类型定义数组指针
- 直接定义数组指针
#include <stdio.h>
void test01()
{
int arr[5] = {1, 2, 3, 4, 5};
typedef int(ARRARY_TYPE)[5];
ARRARY_TYPE * pArr = &arr;
for (int ii = 0; ii < 5; ++ii)
{
printf("%d\n", (*pArr)[ii]);
}
}
void test02()
{
int arr[5] = {1, 2, 3, 4, 5};
typedef int(*ARRARY_TYPE_PTR)[5];
ARRARY_TYPE_PTR pArr = &arr;
for (int ii = 0; ii < 5; ++ii)
{
printf("%d\n", (*pArr)[ii]);
}
}
void test03()
{
int arr[5] = {1, 2, 3, 4, 5};
int (*pArr)[5] = &arr;
for (int ii = 0; ii < 5; ++ii)
{
printf("%d\n", (*pArr)[ii]);
}
}
int main()
{
test01();
test02();
test03();
return 0;
}