C语言—指针和多维数组

作者:追风剑情 发布于:2019-10-11 19:27 分类:C

示例

//Visual Studio中加上这句才可以使用scanf()
//否则只能使用scanf_s()
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdbool.h>

//argc: 参数个数 argv[]: 参数数组
int main(int argc, char *argv[])
{
	int zippo[4][2] = {
		{2, 4}, {6, 8}, {1, 3}, {5, 7}
	};

	printf("zippo=%p, zippo+1=%p\n", zippo, zippo + 1);
	printf("zippo[0]=%p, zippo[0]+1=%p\n", zippo[0], zippo[0] + 1);
	printf("*zippo=%p, *zippo+1=%p\n", *zippo, *zippo + 1);
	//下面三句等价
	printf("zippo[0][0]=%d\n", zippo[0][0]);
	printf("*zippo[0]=%d\n", *zippo[0]);
	printf("**zippo=%d\n", **zippo);
	//下面两句等价
	printf("zippo[2][1]=%d\n", zippo[2][1]);
	printf("*(*(zippo+2)+1)=%d\n", *(*(zippo + 2) + 1));

	system("pause");
	return 0;
}

运行测试
1111.png

标签: C语言

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号