二维数组与指针
标签:size std ide printf img cli hide for com
#include int main()
{
int array[4][5] = {0};
printf("sizeof int: %d\n", sizeof(int));
printf("array: %p\n", array);
printf("array + 1: %p\n", array + 1);
return 0;
}
View Code
#include int main()
{
int array[4][5] = {0};
int i, j, k = 0;
for (i = 0; i 4; i++)
{
for (j = 0; j 5; j++)
{
array[i][j] = k++;
}
}
printf("*(array+1): %p\n", *(array + 1));
printf("array[1]: %p\n", array[1]);
printf("&array[1][0]: %p\n", &array[1][0]);
printf("**(array+1): %d\n", **(array+1));
return 0;
}
View Code
#include int main()
{
int array[4][5] = {0};
int i, j, k = 0;
for (i = 0; i 4; i++)
{
for (j = 0; j 5; j++)
{
array[i][j] = k++;
}
}
printf("*(array+1): %p\n", *(array + 1));
printf("array[1]: %p\n", array[1]);
printf("&array[1][0]: %p\n", &array[1][0]);
printf("**(array+1): %d\n", **(array+1));
printf("*(*(array+1)+3): %d\n", *(*(array+1)+3));
printf("array[1][3]: %d\n", array[1][3]);
return 0;
}
View Code
#include int main()
{
int array[2][3] = {{0, 1, 2}, {3, 4, 5}};
int (*p)[3] = array;
printf("**(p+1): %d\n", **(p+1));
printf("**(array+1): %d\n", **(array+1));
printf("array[1][0]: %d\n", array[1][0]);
printf("*(*(p+1)+2): %d\n", *(*(p+1)+2));
printf("*(*(array+1)+2): %d\n", *(*(array+1)+2));
printf("array[1][2]: %d\n", array[1][2]);
return 0;
}
View Code
二维数组与指针
标签:size std ide printf img cli hide for com
原文地址:https://www.cnblogs.com/helloworld2019/p/11104539.html
文章来自:
搜素材网的
编程语言模块,转载请注明文章出处。
文章标题:
二维数组与指针
文章链接:http://soscw.com/essay/28930.html
评论