首页 > 编程语言 >《黑暗欺骗》c++控制台 2D 版!Alpha 0.2.1

《黑暗欺骗》c++控制台 2D 版!Alpha 0.2.1

时间:2024-02-27 19:45:04浏览次数:31  
标签:now vol 0.2 c++ gto 2D KEY printf else

  • 现在只打了设置这些个东西,游戏主体还没打,那才是难点

已实现功能

游戏

  • 未实现

设置

  • 有音量设置和键盘设置两个功能

存档

  • (这好像是最简单的功能吧?)

注意事项!!!

  • 没错,如你所见,这个游戏我是使用了MCI来播放声音的!
  • 因此,你的DEV-C++需要链接到一个库
  • 打开 工具->编译选项->编译器->编译时加入以下命令->勾选
  • 然后在框里添上下面这个代码
-lwinmm
  • 这样就能成功运行了!
  • 音频文件来这里领 --> 百度网盘,提取码:abcc,放在和.cpp文件同一个文件夹里就行,网盘文件自带源代码。
  • game.h 文件在我之前的一个文章里。(百度网盘也有)传送门 --> <教程> 我的游戏专用头文件 —— game.h
  • body.h文件等会会贴上,百度网盘也有(没办法,就这么一个空壳都640行了,所以就分成几个文件来写)

body.h文件(没错,就这一点,等我打完了再放上来吧)

#ifndef thegamebody
#define thegamebody 1
#include "game.h" //这里可以体现出避免重复引用的重要性
#define GO keymode[1]
#define BACK keymode[2]
#define LEFT keymode[3]
#define RIGHT keymode[4]
#define RUN keymode[5]
#define INTURN keymode[6]
#define STOP keymode[7]
#define MAPMODE keymode[8]
#define SKILL_1 keymode[9]
#define SKILL_2 keymode[10]
#define ENTER keymode[11]
#define MAIN_V vol[1]
#define MUSIC_V vol[2]
#define BUTTON_V vol[3]
#define ENEMY_V vol[4]
#define ENVIR_V vol[5]
#define STEP_V vol[6]

void game() {
	system("mode con cols=80 lines=35");
	
	return ;
}
#endif

最后的最后,贴上现在的(空壳)代码(2023/2/1)

#include "game.h"
#include "body.h"
int isplayed;
int vol[7] = {0, 1000, 1000, 1000, 1000, 1000, 1000};
int keymode[12] = {0, 87, 83, 65, 68, 160, 69, 27, 76, 90, 67, 13};
char volname[7][100] = {"", "", "backmus", "button", "", "", "step"};

void read() {
	FILE *fp = fopen("save", "r");
	for (int i = 1; i < 7; i++) {
		fscanf(fp, "%d", vol + i);
	}
	for (int i = 1; i < 12; i++) {
		fscanf(fp, "%d", keymode + i);
	}
	fclose(fp);
	return ;
}

void save() {
	FILE *fp = fopen("save", "w");
	for (int i = 1; i < 7; i++) {
		fprintf(fp, "%d ", vol[i]);
	}
	for (int i = 1; i < 12; i++) {
		fprintf(fp, "%d ", keymode[i]);
	}
	fclose(fp);
	return ;
}

void resett() {
	save();
	return ;
}

void init() {
	thread test(KD_check);
	test.detach();
	CONSOLE_CURSOR_INFO cursor_info = {1, 0};
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
	srand((unsigned)time(NULL));
	isplayed = Is_File_Exist("save");
	cancelclose();
	mciSendString("open BackMusic.mp3 alias backmus", NULL, 0, NULL);
	mciSendString("open StepSound.mp3 alias step", NULL, 0, NULL);
	mciSendString("open click.mp3 alias button", NULL, 0, NULL);
	if (isplayed == 0) {
		resett();
	} else {
		read();
	}
	set_volume(volname[2], MAIN_V * MUSIC_V / 1000);
	set_volume(volname[6], MAIN_V * STEP_V / 1000);
	set_volume(volname[3], MAIN_V * BUTTON_V / 1000);
	mciSendString("play backmus repeat", NULL, 0, NULL);
	return ;
}

void ss_cover() {
	color(4), system("cls");
	color(4);
	gto(2, 21), printf("--------------------");
	gto(5, 9), printf("音乐音量"), gto(5, 21), printf("--------------------");
	gto(8, 9), printf("按键音量"), gto(8, 21), printf("--------------------");
	gto(11, 9), printf("敌人音量"), gto(11, 21), printf("--------------------");
	gto(14, 9), printf("环境音量"), gto(14, 21), printf("--------------------");
	gto(17, 9), printf("脚步音量"), gto(17, 21), printf("--------------------");
	color(228);
	gto(2, 7), printf("[  主音量  ]"), gto(2, (MAIN_V / 50) + 20), printf("   ");
	gto(5, (MUSIC_V / 50) + 20), printf("   ");
	gto(8, (BUTTON_V / 50) + 20), printf("   ");
	gto(11, (ENEMY_V / 50) + 20), printf("   ");
	gto(14, (ENVIR_V / 50) + 20), printf("   ");
	gto(17, (STEP_V / 50) + 20), printf("   ");
	color(4);
	gto(19, 2);
	printf("按[Esc]退出;按右箭头进入更改;");
	gto(20, 15);
	printf("按%s完成设置", KEY_NAME(ENTER));
	return ;
}

void ssetin(int x) {
	gto(x * 3 - 1, (vol[x] / 50) + 20);
	color(204);
	printf("   ");
	int lst = vol[x], lkt3 = 0, lkt4 = 0;
	bool flag = 0;
	while (1) {
		if (lkt3 != KEY_TIME(37) && KEY_DOWN(37)) {
			lkt3 = KEY_TIME(37);
			if (vol[x] != 0) {
				vol[x] -= 50;
			}
		} else if (lkt4 != KEY_TIME(39) && KEY_DOWN(39)) {
			lkt4 = KEY_TIME(39);
			if (vol[x] != 1000) {
				vol[x] += 50;
			}
		}
		if (vol[x] != lst) {
			if (x == 1) {
				set_volume(volname[2], MAIN_V * MUSIC_V / 1000);
				set_volume(volname[6], MAIN_V * STEP_V / 1000);
				set_volume(volname[3], MAIN_V * BUTTON_V / 1000);
			} else if (x == 2) {
				set_volume(volname[2], MAIN_V * MUSIC_V / 1000);
			} else if (x == 3) {
				set_volume(volname[3], MAIN_V * BUTTON_V / 1000);
			} else if (x == 6) {
				set_volume(volname[6], MAIN_V * STEP_V / 1000);
			}
			play_once(volname[3]);
			gto(x * 3 - 1, (lst / 50) + 20);
			color(4);
			if (lst == 1000) {
				printf("-- ");
			} else if (lst == 0) {
				printf(" --");
			} else {
				printf("---");
			}
			gto(x * 3 - 1, (vol[x] / 50) + 20);
			color(204);
			printf("   ");
			lst = vol[x];
		}
		if (KEY_DOWN(ENTER)) {
			flag = 1;
		} else if (flag) {
			flag = 0;
			play_once(volname[3]);
			break;
		}
		Sleep(50);
	}
	gto(x * 3 - 1, (vol[x] / 50) + 20);
	color(228);
	printf("   ");
	return ;
}

void soundset() {
	ss_cover();
	int now = 1, lst = 1, lkt3 = 0, lkt4 = 0;
	bool flag = 0, ff = 0;
	while (1) {
		if (lkt3 != KEY_TIME(38) && KEY_DOWN(38)) {
			lkt3 = KEY_TIME(38);
			if (now != 1) {
				now--;
			}
			play_once(volname[3]);
		} else if (lkt4 != KEY_TIME(40) && KEY_DOWN(40)) {
			lkt4 = KEY_TIME(40);
			if (now != 6) {
				now++;
			}
			play_once(volname[3]);
		}
		if (now != lst) {
			gto(lst * 3 - 1, 7);
			color(4);
			if (lst == 1) {
				printf("   主音量   ");
			} else if (lst == 2) {
				printf("  音乐音量  ");
			} else if (lst == 3) {
				printf("  按键音量  ");
			} else if (lst == 4) {
				printf("  敌人音量  ");
			} else if (lst == 5) {
				printf("  环境音量  ");
			} else {
				printf("  脚步音量  ");
			}
			gto(now * 3 - 1, 7);
			color(228);
			if (now == 1) {
				printf("[  主音量  ]");
			} else if (now == 2) {
				printf("[ 音乐音量 ]");
			} else if (now == 3) {
				printf("[ 按键音量 ]");
			} else if (now == 4) {
				printf("[ 敌人音量 ]");
			} else if (now == 5) {
				printf("[ 环境音量 ]");
			} else {
				printf("[ 脚步音量 ]");
			}
			color(7);
			lst = now;
		}
		if (KEY_DOWN(39)) {
			ff = 1;
		} else if (ff) {
			play_once(volname[3]);
			ff = 0;
			ssetin(now);
		}
		if (KEY_DOWN(VK_ESCAPE)) {
			flag = 1;
		} else if (flag) {
			play_once(volname[3]);
			flag = 0;
			return ;
		}
		Sleep(50);
	}
	return ;
}

void cs_cover() {
	system("mode con cols=50 lines=24");
	color(4), system("cls");
	color(228), gto(1, 2), printf("[   前进   ]");
	color(4);
	gto(1, 22), printf("%s", KEY_NAME(GO));
	gto(3, 6), printf("后退"), gto(3, 22), printf("%s", KEY_NAME(BACK));
	gto(5, 6), printf("向左"), gto(5, 22), printf("%s", KEY_NAME(LEFT));
	gto(7, 6), printf("向右"), gto(7, 22), printf("%s", KEY_NAME(RIGHT));
	gto(9, 6), printf("疾跑"), gto(9, 22), printf("%s", KEY_NAME(RUN));
	gto(11, 6), printf("交互"), gto(11, 22), printf("%s", KEY_NAME(INTURN));
	gto(13, 6), printf("暂停"), gto(13, 22), printf("%s", KEY_NAME(STOP));
	gto(15, 4), printf("地图大小"), gto(15, 22), printf("%s", KEY_NAME(MAPMODE));
	gto(17, 5), printf("技能一"), gto(17, 22), printf("%s", KEY_NAME(SKILL_1));
	gto(19, 5), printf("技能二"), gto(19, 22), printf("%s", KEY_NAME(SKILL_2));
	gto(21, 5), printf("确认键"), gto(21, 22), printf("%s", KEY_NAME(ENTER));
	color(228);
	gto(8, 32), printf("按[Esc]退出"), gto(10, 32), printf("按右箭头进入更改");
	gto(12, 32), printf("按下对应键以更改");
	color(4);
	return ;
}

void csetin(int x) {
	color(228);
	gto((x << 1) - 1, 17);
	printf("  [  %s  ]  ", KEY_NAME(keymode[x]));
	bool vis[260], flag = 0;
	memset(vis, 0, sizeof(vis));
	while (1) {
		for (int i = 1; i <= 256; i++) {
			if (i == 16) {
				i = 18;
				continue;
			}
			if (KEY_DOWN(i)) {
				vis[i] = 1;
			} else if (vis[i]) {
				keymode[x] = i;
				flag = 1;
				break;
			}
		}
		if (flag) {
			break;
		}
		Sleep(50);
	}
	color(4);
	gto((x << 1) - 1, 17);
	printf("     %s                  ", KEY_NAME(keymode[x]));
	return ;
}

void ctrlset() {
	cs_cover();
	int now = 1, lst = 1, lkt3 = 0, lkt4 = 0;
	bool flag = 0, ff = 0;
	while (1) {
		if (lkt3 != KEY_TIME(38) && KEY_DOWN(38)) {
			lkt3 = KEY_TIME(38);
			if (now != 1) {
				now--;
			}
			play_once(volname[3]);
		} else if (lkt4 != KEY_TIME(40) && KEY_DOWN(40)) {
			lkt4 = KEY_TIME(40);
			if (now != 11) {
				now++;
			}
			play_once(volname[3]);
		}
		if (now != lst) {
			color(4);
			gto((lst << 1) - 1, 2);
			if (lst == 1) {
				printf("    向前    ");
			} else if (lst == 2) {
				printf("    后退    ");
			} else if (lst == 3) {
				printf("    向左    ");
			} else if (lst == 4) {
				printf("    向右    ");
			} else if (lst == 5) {
				printf("    疾跑    ");
			} else if (lst == 6) {
				printf("    交互    ");
			} else if (lst == 7) {
				printf("    暂停    ");
			} else if (lst == 8) {
				printf("  地图大小  ");
			} else if (lst == 9) {
				printf("   技能一   ");
			} else if (lst == 10) {
				printf("   技能二   ");
			} else {
				printf("   确认键   ");
			}
			color(228);
			gto((now << 1) - 1, 2);
			if (now == 1) {
				printf("[   向前   ]");
			} else if (now == 2) {
				printf("[   向后   ]");
			} else if (now == 3) {
				printf("[   向左   ]");
			} else if (now == 4) {
				printf("[   向右   ]");
			} else if (now == 5) {
				printf("[   疾跑   ]");
			} else if (now == 6) {
				printf("[   交互   ]");
			} else if (now == 7) {
				printf("[   暂停   ]");
			} else if (now == 8) {
				printf("[ 地图大小 ]");
			} else if (now == 9) {
				printf("[  技能一  ]");
			} else if (now == 10) {
				printf("[  技能二  ]");
			} else {
				printf("[  确认键  ]");
			}
			color(4);
			lst = now;
		}
		if (KEY_DOWN(39)) {
			ff = 1;
		} else if (ff) {
			play_once(volname[3]);
			color(4);
			gto((now << 1) - 1, 2);
			if (now == 1) {
				printf("    向前    ");
			} else if (now == 2) {
				printf("    后退    ");
			} else if (now == 3) {
				printf("    向左    ");
			} else if (now == 4) {
				printf("    向右    ");
			} else if (now == 5) {
				printf("    疾跑    ");
			} else if (now == 6) {
				printf("    交互    ");
			} else if (now == 7) {
				printf("    暂停    ");
			} else if (now == 8) {
				printf("  地图大小  ");
			} else if (now == 9) {
				printf("   技能一   ");
			} else if (now == 10) {
				printf("   技能二   ");
			} else {
				printf("   确认键   ");
			}
			csetin(now);
			ff = 0;
			color(228);
			gto((now << 1) - 1, 2);
			if (now == 1) {
				printf("[   向前   ]");
			} else if (now == 2) {
				printf("[   向后   ]");
			} else if (now == 3) {
				printf("[   向左   ]");
			} else if (now == 4) {
				printf("[   向右   ]");
			} else if (now == 5) {
				printf("[   疾跑   ]");
			} else if (now == 6) {
				printf("[   交互   ]");
			} else if (now == 7) {
				printf("[   暂停   ]");
			} else if (now == 8) {
				printf("[ 地图大小 ]");
			} else if (now == 9) {
				printf("[  技能一  ]");
			} else if (now == 10) {
				printf("[  技能二  ]");
			} else {
				printf("[  确认键  ]");
			}
			color(4);
		}
		if (KEY_DOWN(VK_ESCAPE)) {
			flag = 1;
		} else if (flag) {
			play_once(volname[3]);
			flag = 0;
			return ;
		}
		Sleep(50);
	}
	return ;
}

void set_cover() {
	system("mode con cols=50 lines=22");
	color(4), system("cls");
	color(228), gto(5, 10), printf("[ 音量设置 ]");
	color(4), gto(10, 12), printf("控制设置"), gto(13, 14), printf("退出");
	color(14), gto(8, 22), printf("按%s以选择", keyname[ENTER]);
	return ;
}

void sett() {
A:
	set_cover();
	int now = 1, lst = 1, lkt3 = 0, lkt4 = 0;
	bool flag = 0;
	while (1) {
		if (lkt3 != KEY_TIME(38) && KEY_DOWN(38)) {
			lkt3 = KEY_TIME(38);
			if (now != 1) {
				now--;
			}
			play_once(volname[3]);
		} else if (lkt4 != KEY_TIME(40) && KEY_DOWN(40)) {
			lkt4 = KEY_TIME(40);
			if (now != 3) {
				now++;
			}
			play_once(volname[3]);
		}
		if (now != lst) {
			color(4);
			if (lst == 1) {
				gto(5, 10);
				printf("  音量设置  ");
			} else if (lst == 2) {
				gto(10, 10);
				printf("  控制设置  ");
			} else {
				gto(13, 10);
				printf("    退出    ");
			}
			color(228);
			if (now == 1) {
				gto(5, 10);
				printf("[ 音量设置 ]");
			} else if (now == 2) {
				gto(10, 10);
				printf("[ 控制设置 ]");
			} else {
				gto(13, 10);
				printf("[   退出   ]");
			}
			color(7);
			lst = now;
		}
		if (KEY_DOWN(ENTER)) {
			flag = 1;
		} else if (flag) {
			play_once(volname[3]);
			flag = 0;
			if (now == 3) {
				return ;
			} else if (now == 1) {
				soundset();
				goto A;
			} else {
				ctrlset();
				goto A;
			}
		}
		Sleep(50);
	}
	return ;
}

void st_cover() {
	color(4);
	system("cls");
	system("mode con cols=50 lines=22");
	color(68);
	//D
	gto(4, 3), printf("       ");
	gto(5, 4), printf("  "), gto(5, 9), printf("   ");
	gto(6, 4), printf("  "), gto(6, 11), printf("  ");
	color(4);
	gto(7, 7), printf("De");
	color(68);
	gto(7, 4), printf("  "), gto(7, 11), printf("  ");
	gto(8, 4), printf("  "), gto(8, 10), printf("  ");
	gto(9, 3), printf("        ");
	//a
	gto(6, 16), printf("     ");
	gto(7, 15), printf("  "), gto(7, 20), printf("  ");
	color(4);
	gto(7, 17);
	printf("cep");
	color(68);
	gto(8, 15), printf("  "), gto(8, 20), printf("  ");
	gto(9, 16), printf("    "), gto(9, 21), printf("  ");
	//r
	gto(6, 24), printf("  "), gto(6, 27), printf("   ");
	gto(7, 24), printf("   "), gto(7, 29), printf("  ");
	gto(8, 24), printf("  ");
	color(4);
	gto(7, 27);
	printf("ti");
	color(68);
	gto(9, 24), printf("  ");
	//k
	gto(4, 33), printf("  ");
	gto(5, 33), printf("  ");
	gto(6, 33), printf("  "), gto(6, 37), printf("   ");
	gto(7, 33), printf("    ");
	color(4);
	gto(7, 38);
	printf("on");
	color(68);
	gto(8, 33), printf("  "), gto(8, 36), printf("  ");
	gto(9, 33), printf("  "), gto(9, 38), printf("   ");
	color(14);
	gto(14, 4);
	printf("按%s以选择", keyname[ENTER]);
	color(228);
	gto(11, 23);
	if (isplayed) {
		printf("[ 继续游戏 ]");
	} else {
		printf("[ 开始游戏 ]");
	}
	color(4);
	if (isplayed) {
		gto(13, 26);
		printf("新游戏");
	}
	gto(15, 27);
	printf("选项");
	gto(17, 27);
	printf("退出");
	color(7);
	return ;
}

bool start() {
A:
	st_cover();
	int now = 1, lst = 1, lkt3 = 0, lkt4 = 0;
	bool flag = 0;
	while (1) {
		if (lkt3 != KEY_TIME(38) && KEY_DOWN(38)) {
			lkt3 = KEY_TIME(38);
			if (now == 3 && isplayed == 0) {
				now = 1;
			} else if (now > 1) {
				now--;
			}
			play_once(volname[3]);
		} else if (lkt4 != KEY_TIME(40) && KEY_DOWN(40)) {
			lkt4 = KEY_TIME(40);
			if (now == 1 && isplayed == 0) {
				now = 3;
			} else if (now < 4) {
				now++;
			}
			play_once(volname[3]);
		}
		if (now != lst) {
			color(4);
			gto((lst << 1) + 9, 23);
			if (lst == 1) {
				if (isplayed) {
					printf("  继续游戏  ");
				} else {
					printf("  开始游戏  ");
				}
			} else if (lst == 2) {
				printf("   新游戏   ");
			} else if (lst == 3) {
				printf("    选项    ");
			} else if (lst == 4) {
				printf("    退出    ");
			}
			color(228);
			gto((now << 1) + 9, 23);
			if (now == 1) {
				if (isplayed) {
					printf("[ 继续游戏 ]");
				} else {
					printf("[ 开始游戏 ]");
				}
			} else if (now == 2) {
				printf("[  新游戏  ]");
			} else if (now == 3) {
				printf("[   选项   ]");
			} else if (now == 4) {
				printf("[   退出   ]");
			}
			color(7);
			lst = now;
		}
		if (KEY_DOWN(ENTER)) {
			flag = 1;
		} else if (flag) {
			play_once(volname[3]);
			flag = 0;
			if (now == 4) {
				return 0;
			} else if (now == 1) {
				game();
				goto A;
			} else if (now == 2) {
				resett();
				game();
				goto A;
			} else if (now == 3) {
				sett();
				goto A;
			}
		}
		Sleep(50);
	}
	return 0;
}

int main() {
	init();
	if (start()) {
		return 0;
	}
	save();
	return 0;
}

标签:now,vol,0.2,c++,gto,2D,KEY,printf,else
From: https://www.cnblogs.com/iloveoi/p/18037699

相关文章

  • [1] C++编程语言
    week9day1 输出指令//控制台打印std::cout<<"HelloWorld";//简化std命名空间usingnamespacestd;//转义字符cout<<"\n";//\n会被渲染成前面有\的前提下\n不会被渲染cout<<"\\n";\n;<<endl;换行; 系统指令//system()可以调用CMD......
  • c++ bind this 实现成员函数代替静态函数
    bind可以用成员函数来替代静态函数。回调函数一般使用静态函数,其中需要传入具体对象的指针,然后该对象的成员变量或函数,都需要加上“对象指针->”这个前缀。bind可以将成员函数用于回调函数。成员函数多了一个隐含的参数this,所以直接用作回调会报错,bind可以将this封装起来(可以理......
  • C++ STL 容器-Vector类型
    C++STL容器-Vector类型std::vector是C++标准库中的一个动态数组容器,它提供了随机访问迭代器,因此你可以像使用普通数组一样使用vector。vector容器可以动态地增长和缩小,这意味着你可以在不预先指定数组大小的情况下向其中添加或删除元素。特点动态大小:vector的大小可以在运......
  • Java中使用Graphics2D实现图片添加文字/图片水印
    场景java实现给图片添加水印实现步骤:获取原图片对象信息(本地图片或网络图片)添加水印(设置水印颜色、字体、坐标等)处理输出目标图片。注:博客:https://blog.csdn.net/badao_liumang_qizhi实现1、新建工具类 importorg.apache.commons.lang3.StringUtils;importjavax.im......
  • C++ STL 容器-array类型
    C++STL容器-array类型array是C++11STL封装的数组,内存分配在栈中stack,绝对不会重新分配,随机访问创建和初始化//下面的等同于inta[10];std::array<int,10>as1;//分配空间但是未初始化std::array<int,10>as2={};//分配空间并且初始化std::array<int,3>as3={1,2,3};基......
  • vc++ 使用base64 编码与解码
        Base64原理Base64是一种基于64个可打印字符来表示二进制数据的表示方法。由于2^6=64,所以每6个比特为一个单元,对应某个可打印字符。3个字节有24个比特,对应于4个Base64单元,即3个字节可由4个可打印字符来表示。它可用来作为电子邮件的传输编码。在B......
  • three.js使用 CSS2DRenderer
    导入 import{CSS2DRenderer,CSS2DObject}from'three/examples/jsm/renderers/CSS2DRenderer';functioncreateLableObj(text,vector){letlaberDiv=document.createElement('div');//创建div容器laberDiv.className='laber_name......
  • Qt Virtual Keyboard C++集成与实现(QWidget)
    一.设置1.配置所需语言1).通过QtCreator配置打开Qt工程文件,点开左侧 Projects->Build->BuildSteps->qmake->Additionalarguments在 Additionalarguments 增加配置参数:CONFIG+="lang-ar_ARlang-da_DKlang-de_DElang-en_GBlang-es_ESlang-fa_FAlang-fi_FIlang-fr......
  • Qt Virtual Keyboard C++集成与实现(解决模态对话框键盘失效问题)
    一.Qt模态对话框先让我们来看看对话框的几种特性:1.Qt::NonModaThewindowisnotmodalanddoesnotblockinputtootherwindows.2.Qt::WindowModalThewindowismodaltoasinglewindowhierarchyandblocksinputtoitsparentwindow,allgrandparentwin......
  • c++引用和指针
    指针和引用当我们需要在程序中传递变量的地址时,可以使用指针或引用。它们都可以用来间接访问变量,但它们之间有一些重要的区别。指针是一个变量,它存储另一个变量的地址。通过指针,我们可以访问存储在该地址中的变量。指针可以被重新分配,可以指向不同的变量,也可以为NULL。指针使用*......