二维数组地址实例

1、&数组名

&数组名是一个二级指针,指的是该二维数组的首地址

&数组名+1的地址与&数组名地址的差为该二维数组的size

2、数组名

数组名可以当作指针使用,指的是该二维数组首行的首地址

数组名+1的地址与数组名地址的差为首行的的长度

数组名+1的地址为第二行的首地址

数组名[0]与*数组名的含义一致

3、*数组名

*数组名指的是二维数组首元素的地址

*数组名+1的地址为第二个元素的地址

4、代码示例

#include<iostream>

int main() {
    
    
	int array[3][3] = {
    
     1, 2, 3 };

	std::cout << "&array地址:" << &array <<  std::endl;
	std::cout << "&array + 1地址:" << &array + 1 << std::endl;
	std::cout << "&array[0] + 1地址:" << &array[0] + 1 << std::endl;
	std::cout << "array地址:" << array << std::endl;
	std::cout << "array + 1地址:" << array + 1 << std::endl;
	std::cout << "array[0] + 1地址:" << array[0] + 1 << std::endl;
	std::cout << "*array地址:" << *array << std::endl;
	std::cout << "*array + 1地址:" << *array + 1 << std::endl;

	return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41936799/article/details/108943523
今日推荐