鸟语天空
C语言—指针和多维数组
post by:追风剑情 2019-10-11 19:27

示例

//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

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容