配列ポインタを定義する3つの方法.
752 ワード
メモ
#include
#include
#include
int main(void)
{
//
#if 0
// method1
// ,
typedef int Buffer[1024];
Buffer *p = NULL;
int a[1024] = { 1 };
p = &a;
for (int i = 0; i < 1024; i++)
{
*((*p) + i) = i + 1;
}
for (int i = 0; i < 1024; i++)
{
printf("%d
",(*p)[i]);
}
#endif
#if 0
// method2
//
typedef int(*P)[10];
int a[10] = { 1,2,3 };
P *p = &a;
for (int i = 0; i < 10; i++)
{
printf("%d
",(*p)[i]);
}
#endif
// method3
// p
int (*p) [10] = NULL;
int a[10] = { 1,2,3 };
p = &a;
system("pause");
return 0;
}