}
//指針與二維數組
//利用指針查看每個元素在內存的地址是多少?
//急事把指針指向每個內存單元的開始
//例如 &date[i][j] 就是去每個元素的地址的意思。
#include
#include
using namespace std;
int main()
{
int date[4][5] = {{1, 2, 3, 4, 5}};
printf("每個元素的地址是:");
for(int i = 0; i < 4; ++i)
{
for(int j = 0; j < 5; ++j)
{
printf("%p\t", &date[i][j]);
}
printf("\n");
}
return 0;
}
//指針的指針
//
//int * *date;
//指向指針變量的指針;
#include
#include
using namespace std;
int main()
{
char *name[] = {"China", "BeiJing", "LongMai"};
char ** p_name;
printf("name[0] :%p\n", name[0]);
printf("name[1] :%p\n", name[1]);
printf("name[2] :%p\n", name[2]);
printf("\n");
p_name = &name[0];
printf("&name[0] : %p\n", p_name);
p_name = &name[1];
printf("&name[1] : %p\n", p_name);
p_name = &name[2];
printf("&name[2] : %p\n", p_name);
printf("\n");
return 0;
}