The system(“pause”) command in C++ is used to pause the execution of a program until the user presses any key. This command is specific to Windows systems and is not portable to other operating systems like Linux or macOS.
#include <stdio.h>
#include <stdlib.h>
int main()
{
// 数组指针是一个**指针**,它指向的是一个数组。
int a[5] = {1, 2, 3, 4, 5};
int (*p)[5] = &a; // 定义一个数组指针,指向一个包含5个int类型元素的数组
// & 把数组当成一个整体
for (int i = 0; i < 5; i++)
{
printf("Value of a[%d] = %d\n", i, (*p)[i]); // 通过数组指针访问数组元素的值
printf("Value of a[%d] = %d\n", i, *(*p + i));
}
system("pause");
return 0;
}这样运行编译后的exe程序,可以暂停程序执行,直到用户按下任意键。