每日一题——指针遍历二维数组

用到了内存地址的知识

#include <iostream>
using namespace std;

int main() {
	int a[2][3] = { 1,2,3,4,5,6 };
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
		cout << *(*(a + i) + j) << endl;
		}
	}
	return 0;
}

运行结果
1
2
3
4
5
6

猜你喜欢

转载自blog.csdn.net/weixin_43574957/article/details/84975045